SearchSuggestionSpec


public final class SearchSuggestionSpec
extends Object implements Parcelable

java.lang.Object
   ↳ android.app.appsearch.SearchSuggestionSpec


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

Summary

Nested classes

class SearchSuggestionSpec.Builder

Builder for objects

Constants

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 constants

int CONTENTS_FILE_DESCRIPTOR

Descriptor bit used with describeContents(): indicates that the Parcelable object's flattened representation includes a file descriptor.

int PARCELABLE_WRITE_RETURN_VALUE

Flag for use with writeToParcel(Parcel, int): the object being written is a return value, that is the result of a function such as "Parcelable someFunction()", "void someFunction(out Parcelable)", or "void someFunction(inout Parcelable)".

Fields

public static final Creator<SearchSuggestionSpec> CREATOR

Public methods

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.

List<String> getSearchStringParameters()

Returns the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function.

void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Inherited methods

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

abstract int describeContents()

Describe the kinds of special objects contained in this Parcelable instance's marshaled representation.

abstract void writeToParcel(Parcel dest, int flags)

Flatten this object in to a Parcel.

Constants

SUGGESTION_RANKING_STRATEGY_DOCUMENT_COUNT

Added in API level 34
Also in T Extensions 7
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 (0x00000000)

SUGGESTION_RANKING_STRATEGY_NONE

Added in API level 34
Also in T Extensions 7
public static final int SUGGESTION_RANKING_STRATEGY_NONE

No Ranking, results are returned in arbitrary order.

Constant Value: 2 (0x00000002)

SUGGESTION_RANKING_STRATEGY_TERM_FREQUENCY

Added in API level 34
Also in T Extensions 7
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 (0x00000001)

Fields

CREATOR

Added in API level 35
Also in T Extensions 13
public static final Creator<SearchSuggestionSpec> CREATOR

Public methods

getFilterDocumentIds

Added in API level 34
Also in T Extensions 7
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 Builder.addFilterDocumentIds 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.

Returns
Map<StringList<String>> This value cannot be null.

getFilterNamespaces

Added in API level 34
Also in T Extensions 7
public List<String> getFilterNamespaces ()

Returns the list of namespaces to search over.

If empty, will search over all namespaces.

Returns
List<String> This value cannot be null.

getFilterProperties

Added in API level 35
Also in T Extensions 13
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 Builder.addFilterPropertyPaths 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.

Returns
Map<StringList<String>> This value cannot be null.

getFilterSchemas

Added in API level 34
Also in T Extensions 7
public List<String> getFilterSchemas ()

Returns the list of schema to search the suggestion over.

If empty, will search over all schemas.

Returns
List<String> This value cannot be null.

getMaximumResultCount

Added in API level 34
Also in T Extensions 7
public int getMaximumResultCount ()

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

Returns
int

getRankingStrategy

Added in API level 34
Also in T Extensions 7
public int getRankingStrategy ()

Returns the ranking strategy.

getSearchStringParameters

Added in T Extensions 16
public List<String> getSearchStringParameters ()

Returns the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function.

Returns
List<String> This value cannot be null.

writeToParcel

Added in API level 35
public void writeToParcel (Parcel dest, 
                int flags)

Flatten this object in to a Parcel.

Parameters
dest Parcel: This value cannot be null.

flags int: Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE. Value is either 0 or a combination of Parcelable.PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES