A query string contains the following three 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 |
Text related to the file's content and metadata, including name, description, and indexable text. Whether the 'title', 'description', 'indexableText' properties, or text in the 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' . |
modifiedTime |
<= , < , = , != , > , >= |
Date of the last modification of the file. RFC 3339 format, default timezone 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 timezone is UTC, e.g., 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 timezone is UTC, e.g., 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 ' . Escape single quotes in queries with \' , such as 'Valentine\'s Day' . |
shortcutDetails.targetId |
= , != |
The ID of the item the shortcut points to. |
Note the following details for operator and query term combinations:
The
contains
operator only performs prefix matching for atitle
term. For example, suppose you have a title ofHelloWorld
, a query oftitle contains 'Hello'
returns a result, but a query oftitle contains 'World'
doesn't.The
contains
operator only performs matching on entire string tokens thefullText
term. For example, if the full text of a document contains the string "HelloWorld" only the queryfullText contains 'HelloWorld'
returns a result.The
contains
operator matches on an exact alphanumeric phrase if it is surrounded by double quotes. For example, if thefullText
of a document contains the string "Hello there world", then the queryfullText contains '"Hello there"'
returns a result, but the queryfullText 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 queryfullText contains '"Hello world"'
returns a result.The
owners
,writers
andreaders
terms are indirectly reflected in the Permissions list and refer to the role on the permission.
Shared drive-specific query terms
The following table lists all valid shared drive query terms. For data types and descriptions, see drives resource reference.
Query term | Valid Operators | Usage | Required useDomainAdminAccess setting |
---|---|---|---|
createdTime |
<= , < , = , != , > , >= |
Date when the shared drive was created. Use RFC 3339 format, default timezone is UTC, e.g., 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 |