SearchSpec

public final class SearchSpec
extends Object

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


This class represents the specification logic for AppSearch. It can be used to set the type of search, like prefix or exact only or apply filters to search for a specific schema type only etc.

Summary

Nested classes

class SearchSpec.Builder

Builder for objects

Constants

int GROUPING_TYPE_PER_NAMESPACE

Results should be grouped together by namespace for the purpose of enforcing a limit on the number of results returned per namespace.

int GROUPING_TYPE_PER_PACKAGE

Results should be grouped together by package for the purpose of enforcing a limit on the number of results returned per package.

int ORDER_ASCENDING

Search results will be returned in an ascending order.

int ORDER_DESCENDING

Search results will be returned in a descending order.

String PROJECTION_SCHEMA_TYPE_WILDCARD

Schema type to be used in SearchSpec.Builder.addProjection(String, Collection) to apply property paths to all results, excepting any types that have had their own, specific property paths set.

int RANKING_STRATEGY_CREATION_TIMESTAMP

Ranked by document creation timestamps.

int RANKING_STRATEGY_DOCUMENT_SCORE

Ranked by app-provided document scores.

int RANKING_STRATEGY_NONE

No Ranking, results are returned in arbitrary order.

int RANKING_STRATEGY_RELEVANCE_SCORE

Ranked by document relevance score.

int RANKING_STRATEGY_SYSTEM_USAGE_COUNT

Ranked by number of usages from a system UI surface.

int RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP

Ranked by timestamp of last usage from a system UI surface.

int RANKING_STRATEGY_USAGE_COUNT

Ranked by number of usages, as reported by the app.

int RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP

Ranked by timestamp of last usage, as reported by the app.

int TERM_MATCH_EXACT_ONLY

Query terms will only match exact tokens in the index.

int TERM_MATCH_PREFIX

Query terms will match indexed tokens when the query term is a prefix of the token.

Public methods

List<String> getFilterNamespaces()

Returns the list of namespaces to search over.

List<String> getFilterPackageNames()

Returns the list of package name filters to search over.

List<String> getFilterSchemas()

Returns the list of schema types to search for.

int getMaxSnippetSize()

Returns the maximum size of a snippet in characters.

int getOrder()

Returns the order of returned search results (descending or ascending).

Map<String, List<String>> getProjections()

Returns a map from schema type to property paths to be used for projection.

int getRankingStrategy()

Returns the ranking strategy.

int getResultCountPerPage()

Returns the number of results per page in the result set.

int getResultGroupingLimit()

Get the maximum number of results to return for each group.

int getResultGroupingTypeFlags()

Get the type of grouping limit to apply, or 0 if SearchSpec.Builder.setResultGrouping(int, int) was not called.

int getSnippetCount()

Returns how many documents to generate snippets for.

int getSnippetCountPerProperty()

Returns how many matches for each property of a matching document to generate snippets for.

int getTermMatch()

Returns how the query terms should match terms in the index.

Inherited methods

Constants

GROUPING_TYPE_PER_NAMESPACE

public static final int GROUPING_TYPE_PER_NAMESPACE

Results should be grouped together by namespace for the purpose of enforcing a limit on the number of results returned per namespace.

Constant Value: 2 (0x00000002)

GROUPING_TYPE_PER_PACKAGE

public static final int GROUPING_TYPE_PER_PACKAGE

Results should be grouped together by package for the purpose of enforcing a limit on the number of results returned per package.

Constant Value: 1 (0x00000001)

ORDER_ASCENDING

public static final int ORDER_ASCENDING

Search results will be returned in an ascending order.

Constant Value: 1 (0x000000