Google is committed to advancing racial equity for Black communities. See how.


public interface SearchableOrderedMetadataField implements SearchableMetadataField<T>

Interface for metadata fields which holds an ordered value (such as a date) and which can be used for range queries. Implementations of this interface (such as the static values in SearchableField) can be used to create inequality filters for file queries.

For example, the following code will find all files that were modified in the last hour with the MIME type "text/plain":

 Date oneHourAgo = new Date(System.currentTimeMillis() - (60 * 60 * 1000));
 Filter dateFilter = Filters.greaterThan(SearchableField.MODIFIED_DATE, oneHourAgo);
 Filter mimeTypeFilter = Filters.eq(SearchableField.MIME_TYPE, "text/plain");
 Query query = new Query.Builder().addFilters(dateFilter, mimeTypeFilter).build();
 for (Metadata metadata : Drive.DriveApi.query(apiClient, query).await().getMetadataBuffer()) {

Note that you must pass an SearchableOrderedMetadataField to the Filters#greaterThan, Filters#lessThan, Filters#lessThanEquals, or Filters#greaterThanEquals methods; a plain SearchableMetadataField cannot be used as part of an inequality query. However, every SearchableOrderedMetadataField is also a SearchableMetadataField, so you can use a SearchableOrderedMetadataField with Filters#eq (for example, if you want to find a file that was modified at an exact time).