SearchSpec.Builder

public static final class SearchSpec.Builder
extends Object

java.lang.Object
   ↳ androidx.appsearch.app.SearchSpec.Builder


Builder for objects.

Summary

Public constructors

Builder()

Public methods

SearchSpec.Builder addFilterDocumentClasses(Class...<?> documentClasses)

Adds the Schema names of given document classes to the Schema type filter of SearchSpec Entry.

SearchSpec.Builder addFilterDocumentClasses(Collection<? extends Class<?>> documentClasses)

Adds the Schema names of given document classes to the Schema type filter of SearchSpec Entry.

SearchSpec.Builder addFilterNamespaces(String... namespaces)

Adds a namespace filter to SearchSpec Entry.

SearchSpec.Builder addFilterNamespaces(Collection<String> namespaces)

Adds a namespace filter to SearchSpec Entry.

SearchSpec.Builder addFilterPackageNames(String... packageNames)

Adds a package name filter to SearchSpec Entry.

SearchSpec.Builder addFilterPackageNames(Collection<String> packageNames)

Adds a package name filter to SearchSpec Entry.

SearchSpec.Builder addFilterSchemas(Collection<String> schemas)

Adds a Schema type filter to SearchSpec Entry.

SearchSpec.Builder addFilterSchemas(String... schemas)

Adds a Schema type filter to SearchSpec Entry.

SearchSpec.Builder addProjection(String schema, Collection<String> propertyPaths)

Adds property paths for the specified type to be used for projection.

SearchSpec build()

Constructs a new SearchSpec from the contents of this builder.

SearchSpec.Builder setMaxSnippetSize(int maxSnippetSize)

Sets maxSnippetSize, the maximum snippet size.

SearchSpec.Builder setOrder(int order)

Indicates the order of returned search results, the default is SearchSpec.ORDER_DESCENDING, meaning that results with higher scores come first.

SearchSpec.Builder setRankingStrategy(int rankingStrategy)

Sets ranking strategy for AppSearch results.

SearchSpec.Builder setResultCountPerPage(int resultCountPerPage)

Sets the number of results per page in the returned object.

SearchSpec.Builder setResultGrouping(int groupingTypeFlags, int limit)

Set the maximum number of results to return for each group, where groups are defined by grouping type.

SearchSpec.Builder setSnippetCount(int snippetCount)

Only the first snippetCount documents based on the ranking strategy will have snippet information provided.

SearchSpec.Builder setSnippetCountPerProperty(int snippetCountPerProperty)

Sets snippetCountPerProperty.

SearchSpec.Builder setTermMatch(int termMatchType)

Indicates how the query terms should match TermMatchCode in the index.

Inherited methods

Public constructors

Builder

public Builder ()

Public methods

addFilterDocumentClasses

public SearchSpec.Builder addFilterDocumentClasses (Class...<?> documentClasses)

Adds the Schema names of given document classes to the Schema type filter of SearchSpec Entry. Only search for documents that have the specified schema types.

If unset, the query will search over all schema types.

Parameters
documentClasses Class: classes annotated with Document.

Returns
SearchSpec.Builder

Throws
AppSearchException

addFilterDocumentClasses

public SearchSpec.Builder addFilter