AppSearchSession.SearchSuggestion Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Retrieves suggested Strings that could be used as queryExpression
in #search(String, SearchSpec)
API.
[Android.Runtime.Register("searchSuggestion", "(Ljava/lang/String;Landroid/app/appsearch/SearchSuggestionSpec;Ljava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "", ApiSince=34)]
public void SearchSuggestion (string suggestionQueryExpression, Android.App.AppSearch.SearchSuggestionSpec searchSuggestionSpec, Java.Util.Concurrent.IExecutor executor, Java.Util.Functions.IConsumer callback);
[<Android.Runtime.Register("searchSuggestion", "(Ljava/lang/String;Landroid/app/appsearch/SearchSuggestionSpec;Ljava/util/concurrent/Executor;Ljava/util/function/Consumer;)V", "", ApiSince=34)>]
member this.SearchSuggestion : string * Android.App.AppSearch.SearchSuggestionSpec * Java.Util.Concurrent.IExecutor * Java.Util.Functions.IConsumer -> unit
Parameters
- suggestionQueryExpression
- String
the non empty query string to search suggestions
- searchSuggestionSpec
- SearchSuggestionSpec
spec for setting document filters
- executor
- IExecutor
Executor on which to invoke the callback.
- callback
- IConsumer
Callback to receive the pending result of performing this operation, which is
a List of SearchSuggestionResult
on success. The returned suggestion Strings are
ordered by the number of SearchResult
you could get by using that suggestion in
#search
.
- Attributes
Remarks
Retrieves suggested Strings that could be used as queryExpression
in #search(String, SearchSpec)
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.
<ul> <li>document1: "term1" <li>document2: "term1 term2" <li>document3: "term1 term2 term3" <li>document4: "org" </ul>
Search suggestions with the single term suggestionQueryExpression
"t", the suggested results are:
<ul> <li>"term1" - Use it to be queryExpression in #search
could get 3 SearchResult
s, which contains document 1, 2 and 3. <li>"term2" - Use it to be queryExpression in #search
could get 2 SearchResult
s, which contains document 2 and 3. <li>"term3" - Use it to be queryExpression in #search
could get 1 SearchResult
, which contains document 3. </ul>
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
are supported.
<b>NOTE:</b> Exclusion and Grouped Terms in the last term is not supported.
example: "apple -f": This Api will throw an android.app.appsearch.exceptions.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.
<ul> <li>"" - Empty suggestionQueryExpression
. <li>"(f)" - Ending in a closed brackets. <li>"f:" - Ending in an operator. <li>"f " - Ending in trailing space. </ul>
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.