Client class for AppSearch. An instance of this class can be created using AppSearch
to provide a connection to a single AppSearch database.
Closes the AppSearchClient
to persist all schema and document updates, additions, and deletes to disk.
Retrieves the set of all namespaces in the target database with at least one document.
Parameters databaseName the name of the database all namespaces belong to. public abstract Task<StorageInfo> getStorageInfo (String databaseName)Gets the storage info for the specified database.
This may take time proportional to the number of documents and may be inefficient to call repeatedly.
Parameters databaseName the name of the database. public abstract Task<Void> remove (String queryExpression, SearchSpec searchSpec, String databaseName) Parameters queryExpression Query String to search. searchSpec Spec containing schemaTypes, namespaces and query expression indicates how document will be removed. All specific about how to scoring, ordering, snippeting and resulting will be ignored. databaseName the name of the database this remove targets. public abstract Task<Void> reportUsage (ReportUsageRequest reportUsageRequest, String databaseName) Parameters reportUsageRequest The usage reporting request. databaseName the name of the database the reported documents belong to. public abstract SearchResults search (String queryExpression, SearchSpec searchSpec, String databaseName)Retrieves documents from the specified database that match a given query string and type of search provided.
Query strings can be empty, contain one term with no operators, or contain multiple terms and operators.
For query strings that are empty, all documents that match the SearchSpec
will be returned.
For query strings with a single term and no operators, documents that match the provided query string and SearchSpec
will be returned.
The following operators are supported:
AND is an operator that matches documents that contain all provided terms.
NOTE: A space between terms is treated as an "AND" operator. Explicitly including "AND" in a query string will treat "AND" as a term, returning documents that also contain "AND".
Example: "apple AND banana" matches documents that contain the terms "apple", "and", "banana".
Example: "apple banana" matches documents that contain both "apple" and "banana".
Example: "apple banana cherry" matches documents that contain "apple", "banana", and "cherry".
OR is an operator that matches documents that contain any provided term.
Example: "apple OR banana" matches documents that contain either "apple" or "banana".
Example: "apple OR banana OR cherry" matches documents that contain any of "apple", "banana", or "cherry".
Exclusion (-) is an operator that matches documents that do not contain the provided term.
Example: "-apple" matches documents that do not contain "apple".
For queries that require multiple operators and terms, terms can be grouped into subqueries. Subqueries are contained within an open "(" and close ")" parenthesis.
Example: "(donut OR bagel) (coffee OR tea)" matches documents that contain either "donut" or "bagel" and either "coffee" or "tea".
For queries that require a term to match a specific AppSearchSchema
property of a document, a ":" must be included between the property name and the term.
Example: "subject:important" matches documents that contain the term "important" in the "subject" property.
Additional search specifications, such as filtering by AppSearchSchema
type or adding projection, can be set by calling the corresponding SearchSpec.Builder
setter.
This method is lightweight. The heavy work will be done in SearchResults.getNextPage()
.
Retrieves suggested Strings that could be used as queryExpression
in search(String, SearchSpec, String)
API.
The suggestionQueryExpression
can contain one term with no operators, or contain multiple terms and operators. Operators will be considered as a normal term. Please see the operator examples below. The suggestionQueryExpression
must end with a valid term, the suggestions are generated based on the last term. If the input suggestionQueryExpression
doesn't have a valid token, AppSearch will return an empty result list. Please see the invalid examples below.
Example: if there are following documents with content stored in AppSearch.
Search suggestions with the single term suggestionQueryExpression
"t", the suggested results are:
search(String, SearchSpec, String)
could get 3 SearchResult
s, which contains document 1, 2 and 3. search(String, SearchSpec, String)
could get 2 SearchResult
s, which contains document 2 and 3. search(String, SearchSpec, String)
could get 1 SearchResult
, which contains document 3.Search suggestions with the multiple term suggestionQueryExpression
"org t", the suggested result will be "org term1" - The last token is completed by the suggested String.
Operators in search(String, SearchSpec, String)
are supported.
NOTE: Exclusion and Grouped Terms in the last term is not supported.
example: "apple -f": This Api will throw an AppSearchException
with AppSearchResult.RESULT_INVALID_ARGUMENT
.
example: "apple (f)": This Api will return an empty results.
Invalid example: All these input suggestionQueryExpression
don't have a valid last token, AppSearch will return an empty result list.
suggestionQueryExpression
.Sets the schema that represents the organizational structure of data within the Google Play services AppSearch database.
Upon creating an AppSearchClient
, setSchema(SetSchemaRequest, String)
should be called. If the schema needs to be updated, or it has not been previously set, then the provided schema will be saved and persisted to disk. Otherwise, setSchema(SetSchemaRequest, String)
is handled efficiently as a no-op call.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4