SearchSuggestionSpec

public final class SearchSuggestionSpec extends Object
implements Parcelable

This class represents the specification logic for AppSearch. It can be used to set the filter and settings of search a suggestions.

Nested Class Summary

class SearchSuggestionSpec.Builder Builder for objects

Constant Summary

int SUGGESTION_RANKING_STRATEGY_DOCUMENT_COUNT Ranked by the document count that contains the term.
int SUGGESTION_RANKING_STRATEGY_NONE No Ranking, results are returned in arbitrary order.
int SUGGESTION_RANKING_STRATEGY_TERM_FREQUENCY Ranked by the term appear frequency.

Inherited Constant Summary

Field Summary

public static final Creator<SearchSuggestionSpec> CREATOR

Public Method Summary

Map<StringList<String>>
getFilterDocumentIds()
Returns the map of namespace and target document ids to search over.
List<String>
getFilterNamespaces()
Returns the list of namespaces to search over.
Map<StringList<String>>
getFilterProperties()
Returns the map of schema and target properties to search over.
List<String>
getFilterSchemas()
Returns the list of schema to search the suggestion over.
int
getMaximumResultCount()
Returns the maximum number of wanted suggestion that will be returned in the result object.
int
getRankingStrategy()
Returns the ranking strategy.
void
writeToParcel(Parcel dest, int flags)

Inherited Method Summary

Constants

public static final int SUGGESTION_RANKING_STRATEGY_DOCUMENT_COUNT

Ranked by the document count that contains the term.

Suppose the following document is in the index.

Doc1 contains: term1 term2 term2 term2
Doc2 contains: term1

Then, suppose that a search suggestion for "t" is issued with the DOCUMENT_COUNT, the returned SearchSuggestionResults will be: term1, term2. The term1 will have higher score and appear in the results first.

Constant Value: 0

public static final int SUGGESTION_RANKING_STRATEGY_NONE

No Ranking, results are returned in arbitrary order.

Constant Value: 2

public static final int SUGGESTION_RANKING_STRATEGY_TERM_FREQUENCY

Ranked by the term appear frequency.

Suppose the following document is in the index.

Doc1 contains: term1 term2 term2 term2
Doc2 contains: term1

Then, suppose that a search suggestion for "t" is issued with the TERM_FREQUENCY, the returned SearchSuggestionResults will be: term2, term1. The term2 will have higher score and appear in the results first.

Constant Value: 1

Fields

public static final Creator<SearchSuggestionSpec> CREATOR

Public Methods

public Map<StringList<String>> getFilterDocumentIds ()

Returns the map of namespace and target document ids to search over.

The keys of the returned map are namespaces, and the values are the target document ids in that namespace to search over.

If SearchSuggestionSpec.Builder.addFilterDocumentIds(String, String...) was never called, returns an empty map. In this case AppSearch will search over all namespace and document ids.

Calling this function repeatedly is inefficient. Prefer to retain the Map returned by this function, rather than calling it multiple times.

public List<String> getFilterNamespaces ()

Returns the list of namespaces to search over.

If empty, will search over all namespaces.

public Map<StringList<String>> getFilterProperties ()

Returns the map of schema and target properties to search over.

The keys of the returned map are schema types, and the values are the target property path in that schema to search over.

If SearchSuggestionSpec.Builder.addFilterPropertyPaths(String, Collection) was never called, returns an empty map. In this case AppSearch will search over all schemas and properties.

Calling this function repeatedly is inefficient. Prefer to retain the Map returned by this function, rather than calling it multiple times.

public List<String> getFilterSchemas ()

Returns the list of schema to search the suggestion over.

If empty, will search over all schemas.

public int getMaximumResultCount ()

Returns the maximum number of wanted suggestion that will be returned in the result object.

public int getRankingStrategy ()

Returns the ranking strategy.

public void writeToParcel (Parcel dest, int flags)