SearchableOrderedMetadataField
Stay organized with collections
Save and categorize content based on your preferences.
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()) {
System.out.println(metadata.getTitle());
}
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).
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["`SearchableOrderedMetadataField` allows range queries on ordered metadata like dates, enabling filters like \"greater than\" or \"less than\"."],["It's used for creating inequality filters in file queries, unlike `SearchableMetadataField` which is for equality checks."],["Implementations, found in `SearchableField`, facilitate creating these filters for querying files based on criteria like modification date."],["While designed for range queries, `SearchableOrderedMetadataField` can also be used with `Filters#eq` for exact matches."]]],["`SearchableOrderedMetadataField` enables range queries for ordered metadata, like dates. Use implementations, such as those in `SearchableField`, with `Filters.greaterThan`, `lessThan`, `lessThanEquals`, or `greaterThanEquals` to create inequality filters. For instance, filter files modified in the last hour by using the modified date. `SearchableOrderedMetadataField` can also be employed with `Filters.eq` for exact-match queries, despite needing to use `SearchableMetadataField` for non-ordered data.\n"]]