Search query terms and operators

Stay organized with collections Save and categorize content based on your preferences.

A query string contains the following 3 parts:

query_term operator values

Where:

  • query_term is the query term or field to search upon.

  • operator specifies the condition for the query term.

  • values are the specific values you want to use to filter your search results.

This reference provides the query terms and operators you can use with the Drive API.

Query operators

This table lists all valid query operators:

Operator Usage
contains The content of one string is present in the other.
= The content of a string or boolean is equal to the other.
!= The content of a string or boolean is not equal to the other.
< A value is less than another.
<= A value is less than or equal to another.
> A value is greater than another.
>= A value is greater than or equal to another.
in An element is contained within a collection.
and Return items that match both queries.
or Return items that match either query.
not Negates a search query.
has A collection contains an element matching the parameters.

File-specific query terms

The following table lists all valid file query terms. For data types and descriptions, refer to the files resource reference.

Query term Valid operators Usage
name contains, =, != Name of the file. Surround with single quotes '. Escape single quotes in queries with \', such as 'Valentine\'s Day'.
fullText contains Whether the name, description, indexableText properties, or text in the file's content or metadata of the file matches. Surround with single quotes '. Escape single quotes in queries with \', such as 'Valentine\'s Day'.
mimeType contains, =, != MIME type of the file. Surround with single quotes '. Escape single quotes in queries with \', such as 'Valentine\'s Day'. For further information on MIME types, see Google Workspace and Drive MIME Types.
modifiedTime <=, <, =, !=, >, >= Date of the last modification of the file. RFC 3339 format, default time zone is UTC, such as 2012-06-04T12:00:00-08:00. Fields of type date are not currently comparable to each other, only to constant dates.
viewedByMeTime <=, <, =, !=, >, >= Date that the user last viewed a file. RFC 3339 format, default time zone is UTC, such as 2012-06-04T12:00:00-08:00. Fields of type date are not currently comparable to each other, only to constant dates.
trashed =, != Whether the file is in the trash or not. Can be either true or false.
starred =, != Whether the file is starred or not. Can be either true or false.
parents in Whether the parents collection contains the specified ID.
owners in Users who own the file.
writers in Users or groups who have permission to modify the file. See Permissions resource reference.
readers in Users or groups who have permission to read the file. See Permissions resource reference.
sharedWithMe =, != Files that are in the user's "Shared with me" collection. All file users are in the file's Access Control List (ACL). Can be either true or false.
createdTime <=, <, =, !=, >, >= Date when the shared drive was created. Use RFC 3339 format, default time zone is UTC, such as 2012-06-04T12:00:00-08:00.
properties has Public custom file properties.
appProperties has Private custom file properties.
visibility =, != The visibility level of the file. Valid values are anyoneCanFind, anyoneWithLink, domainCanFind, domainWithLink, and limited. Surround with single quotes '.
shortcutDetails.targetId =, != The ID of the item the shortcut points to.

The following demonstrates operator and query term combinations:

  • The contains operator only performs prefix matching for a name term. For example, suppose you have a name of HelloWorld. A query of name contains 'Hello' returns a result, but a query of name contains 'World' doesn't.

  • The contains operator only performs matching on entire string tokens for the fullText term. For example, if the full text of a document contains the string "HelloWorld", only the query fullText contains 'HelloWorld' returns a result.

  • The contains operator matches on an exact alphanumeric phrase if it's surrounded by double quotes. For example, if the fullText of a document contains the string "Hello there world", then the query fullText contains '"Hello there"' returns a result, but the query fullText contains '"Hello world"' doesn't. Furthermore, since the search is alphanumeric, if the full text of a document contains the string "Hello_world", then the query fullText contains '"Hello world"' returns a result.

  • The owners, writers, and readers terms are indirectly reflected in the Permissions list and refer to the role on the permission.

For more examples of query string searches, see Query string examples.

Shared drive-specific query terms

The following table lists all valid shared drive query terms. For data types and descriptions, see the drives resource reference.

Query term Valid Operators Usage Required useDomainAdminAccess setting
createdTime <=, <, =, !=, >, >= Date when the shared drive was created. RFC 3339 format, default time zone is UTC, such as 2012-06-04T12:00:00-08:00. true
hidden =, != Specifies whether or not the shared drive is hidden. Can be either true or false. false
memberCount <=, <, =, !=, >, >= Number of users and groups that are members of the shared drive. Takes a numerical value. true
name contains, =, != Name of the shared drive. Surround with single quotes '. Escape single quotes in queries with \', such as 'Valentine\'s Day'. false
organizerCount <=, <, =, !=, >, >= Number of users and groups that are organizers of the shared drive. Takes a numerical value. true
orgUnitId =, != The Organizational Unit (OU) ID of a shared drive. Takes a string value. true