Added in API level 31

SearchSpec


class SearchSpec : Parcelable
kotlin.Any
   ↳ android.app.appsearch.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

Builder for objects.

Constants
static Int

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

static Int

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

static Int

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

static Int

Search results will be returned in an ascending order.

static Int

Search results will be returned in a descending order.

static String

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

static Int

Ranked by the advanced ranking expression provided.

static Int

Ranked by document creation timestamps.

static Int

Ranked by app-provided document scores.

static Int

Ranked by the aggregated ranking signal of the joined documents.

static Int

No Ranking, results are returned in arbitrary order.

static Int

Ranked by document relevance score.

static Int

Ranked by number of usages from a system UI surface.

static Int

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

static Int

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

static Int

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

static String

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

static Int

Query terms will only match exact tokens in the index.

static Int

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

Inherited constants
Public methods
String

Get the advanced ranking expression, or "" if Builder#setRankingStrategy(String) was not called.

MutableList<String!>

Returns the list of namespaces to search over.

MutableList<String!>

Returns the list of package name filters to search over.

MutableMap<String!, MutableList<String!>!>

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

MutableList<String!>

Returns the list of schema types to search for.

JoinSpec?

Returns specification on which documents need to be joined.

Int

Returns the maximum size of a snippet in characters.

Int

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

MutableMap<String!, MutableList<PropertyPath!>!>

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

MutableMap<String!, MutableList<String!>!>

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

MutableMap<String!, MutableMap<PropertyPath!, Double!>!>

Returns properties weights to be used for scoring.

MutableMap<String!, MutableMap<String!, Double!>!>

Returns properties weights to be used for scoring.

Int

Returns the ranking strategy.

Int

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

Int

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

Int

Get the type of grouping limit to apply, or 0 if Builder#setResultGrouping was not called.

String?

Gets a tag to indicate the source of this search, or null if android.app.appsearch.SearchSpec.Builder#setSearchSourceLogTag(java.lang.String) was not called.

Int

Returns how many documents to generate snippets for.

Int

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

Int

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

Boolean

Returns whether the LIST_FILTER_HAS_PROPERTY_FUNCTION feature is enabled.

Boolean

Returns whether the LIST_FILTER_QUERY_LANGUAGE feature is enabled.

Boolean

Returns whether the NUMERIC_SEARCH feature is enabled.

Boolean

Returns whether the VERBATIM_SEARCH feature is enabled.

Unit
writeToParcel(dest: Parcel, flags: Int)

Flatten this object in to a Parcel.

Properties
static Parcelable.Creator<SearchSpec!>

Creator class for SearchSpec.

Constants

GROUPING_TYPE_PER_NAMESPACE

Added in API level 31
static val GROUPING_TYPE_PER_NAMESPACE: Int

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

Value: 2

GROUPING_TYPE_PER_PACKAGE

Added in API level 31
static val GROUPING_TYPE_PER_PACKAGE: Int

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

Value: 1

GROUPING_TYPE_PER_SCHEMA

static val GROUPING_TYPE_PER_SCHEMA: Int

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

Value: 4

ORDER_ASCENDING

Added in API level 31
static val ORDER_ASCENDING: Int

Search results will be returned in an ascending order.

Value: 1

ORDER_DESCENDING

Added in API level 31
static val ORDER_DESCENDING: Int

Search results will be returned in a descending order.

Value: 0

PROJECTION_SCHEMA_TYPE_WILDCARD

static val PROJECTION_SCHEMA_TYPE_WILDCARD: String

Deprecated: use SCHEMA_TYPE_WILDCARD instead.

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

Value: "*"

RANKING_STRATEGY_ADVANCED_RANKING_EXPRESSION

Added in API level 34
static val RANKING_STRATEGY_ADVANCED_RANKING_EXPRESSION: Int

Ranked by the advanced ranking expression provided.

Value: 9

RANKING_STRATEGY_CREATION_TIMESTAMP

Added in API level 31
static val RANKING_STRATEGY_CREATION_TIMESTAMP: Int

Ranked by document creation timestamps.

Value: 2

RANKING_STRATEGY_DOCUMENT_SCORE

Added in API level 31
static val RANKING_STRATEGY_DOCUMENT_SCORE: Int

Ranked by app-provided document scores.

Value: 1

RANKING_STRATEGY_JOIN_AGGREGATE_SCORE

Added in API level 34
static val RANKING_STRATEGY_JOIN_AGGREGATE_SCORE: Int

Ranked by the aggregated ranking signal of the joined documents.

Which aggregation strategy is used to determine a ranking signal is specified in the JoinSpec set by Builder#setJoinSpec. This ranking strategy may not be used if no JoinSpec is provided.

Value: 8

RANKING_STRATEGY_NONE

Added in API level 31
static val RANKING_STRATEGY_NONE: Int

No Ranking, results are returned in arbitrary order.

Value: 0

RANKING_STRATEGY_RELEVANCE_SCORE

Added in API level 31
static val RANKING_STRATEGY_RELEVANCE_SCORE: Int

Ranked by document relevance score.

Value: 3

RANKING_STRATEGY_SYSTEM_USAGE_COUNT

Added in API level 31
static val RANKING_STRATEGY_SYSTEM_USAGE_COUNT: Int

Ranked by number of usages from a system UI surface.

Value: 6

RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP

Added in API level 31
static val RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP: Int

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

Value: 7

RANKING_STRATEGY_USAGE_COUNT

Added in API level 31
static val RANKING_STRATEGY_USAGE_COUNT: Int

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

Value: 4

RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP

Added in API level 31
static val RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP: Int

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

Value: 5

SCHEMA_TYPE_WILDCARD

static val SCHEMA_TYPE_WILDCARD: String

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

Value: "*"

TERM_MATCH_EXACT_ONLY

Added in API level 31
static val TERM_MATCH_EXACT_ONLY: Int

Query terms will only match exact tokens in the index.

For example, a query term "foo" will only match indexed token "foo", and not "foot" or "football".

Value: 1

TERM_MATCH_PREFIX

Added in API level 31
static val TERM_MATCH_PREFIX: Int

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

For example, a query term "foo" will match indexed tokens like "foo", "foot", and "football".

Value: 2

Public methods

getAdvancedRankingExpression

Added in API level 34
fun getAdvancedRankingExpression(): String

Get the advanced ranking expression, or "" if Builder#setRankingStrategy(String) was not called.

Return
String This value cannot be null.

getFilterNamespaces

Added in API level 31
fun getFilterNamespaces(): MutableList<String!>

Returns the list of namespaces to search over.

If empty, the query will search over all namespaces.

Return
MutableList<String!> This value cannot be null.

getFilterPackageNames

Added in API level 31
fun getFilterPackageNames(): MutableList<String!>

Returns the list of package name filters to search over.

If empty, the query will search over all packages that the caller has access to. If package names are specified which caller doesn't have access to, then those package names will be ignored.

Return
MutableList<String!> This value cannot be null.

getFilterProperties

fun getFilterProperties(): MutableMap<String!, MutableList<String!>!>

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

If empty, will search over all schema and properties.

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

Return
MutableMap<String!, MutableList<String!>!> This value cannot be null.

getFilterSchemas

Added in API level 31
fun getFilterSchemas(): MutableList<String!>

Returns the list of schema types to search for.

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

Return
MutableList<String!> This value cannot be null.

getJoinSpec

Added in API level 34
fun getJoinSpec(): JoinSpec?

Returns specification on which documents need to be joined.

Return
JoinSpec? This value may be null.

getMaxSnippetSize

Added in API level 31
fun getMaxSnippetSize(): Int

Returns the maximum size of a snippet in characters.

getOrder

Added in API level 31
fun getOrder(): Int

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

Return
Int Value is android.app.appsearch.SearchSpec#ORDER_DESCENDING, or android.app.appsearch.SearchSpec#ORDER_ASCENDING

getProjectionPaths

Added in API level 34
fun getProjectionPaths(): MutableMap<String!, MutableList<PropertyPath!>!>

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

If the map is empty, then all properties will be retrieved for all results.

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

Return
MutableMap<String!, MutableList<PropertyPath!>!> A mapping of schema types to lists of projection PropertyPath objects. This value cannot be null.

getProjections

Added in API level 31
fun getProjections(): MutableMap<String!, MutableList<String!>!>

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

If the map is empty, then all properties will be retrieved for all results.

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

Return
MutableMap<String!, MutableList<String!>!> A mapping of schema types to lists of projection strings. This value cannot be null.

getPropertyWeightPaths

Added in API level 34
fun getPropertyWeightPaths(): MutableMap<String!, MutableMap<PropertyPath!, Double!>!>

Returns properties weights to be used for scoring.

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

Return
MutableMap<String!, MutableMap<PropertyPath!, Double!>!> a Map of schema type to an inner-map of property paths of the schema type to the weight to set for that property. This value cannot be null.

getPropertyWeights

Added in API level 34
fun getPropertyWeights(): MutableMap<String!, MutableMap<String!, Double!>!>

Returns properties weights to be used for scoring.

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

Return
MutableMap<String!, MutableMap<String!, Double!>!> a Map of schema type to an inner-map of property paths of the schema type to the weight to set for that property. This value cannot be null.

getResultCountPerPage

Added in API level 31
fun getResultCountPerPage(): Int

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

getResultGroupingLimit

Added in API level 31
fun getResultGroupingLimit(): Int

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

Return
Int the maximum number of results to return for each group or Integer.MAX_VALUE if android.app.appsearch.SearchSpec.Builder#setResultGrouping(int,int) was not called.

getResultGroupingTypeFlags

Added in API level 31
fun getResultGroupingTypeFlags(): Int

Get the type of grouping limit to apply, or 0 if Builder#setResultGrouping was not called.

Return
Int Value is either 0 or a combination of android.app.appsearch.SearchSpec#GROUPING_TYPE_PER_PACKAGE, android.app.appsearch.SearchSpec#GROUPING_TYPE_PER_NAMESPACE, and android.app.appsearch.SearchSpec#GROUPING_TYPE_PER_SCHEMA

getSearchSourceLogTag

fun getSearchSourceLogTag(): String?

Gets a tag to indicate the source of this search, or null if android.app.appsearch.SearchSpec.Builder#setSearchSourceLogTag(java.lang.String) was not called.

Some AppSearch implementations may log a hash of this tag using statsd. This tag may be used for tracing performance issues and crashes to a component of an app.

Call Builder#setSearchSourceLogTag and give a unique value if you want to distinguish this search scenario with other search scenarios during performance analysis.

Under no circumstances will AppSearch log the raw String value using statsd, but it will be provided as-is to custom AppSearchLogger implementations you have registered in your app.

getSnippetCount

Added in API level 31
fun getSnippetCount(): Int

Returns how many documents to generate snippets for.

getSnippetCountPerProperty

Added in API level 31
fun getSnippetCountPerProperty(): Int

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

getTermMatch

Added in API level 31
fun getTermMatch(): Int

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

Return
Int Value is android.app.appsearch.SearchSpec#TERM_MATCH_EXACT_ONLY, or android.app.appsearch.SearchSpec#TERM_MATCH_PREFIX

isListFilterHasPropertyFunctionEnabled

fun isListFilterHasPropertyFunctionEnabled(): Boolean

Returns whether the LIST_FILTER_HAS_PROPERTY_FUNCTION feature is enabled.

isListFilterQueryLanguageEnabled

Added in API level 34
fun isListFilterQueryLanguageEnabled(): Boolean

Returns whether the LIST_FILTER_QUERY_LANGUAGE feature is enabled.

isNumericSearchEnabled

Added in API level 34
fun isNumericSearchEnabled(): Boolean

Returns whether the NUMERIC_SEARCH feature is enabled.

isVerbatimSearchEnabled

Added in API level 34
fun isVerbatimSearchEnabled(): Boolean

Returns whether the VERBATIM_SEARCH feature is enabled.

writeToParcel

fun writeToParcel(
    dest: Parcel,
    flags: Int
): Unit

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_WRITE_RETURN_VALUE. Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE, and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES

Properties

CREATOR

static val CREATOR: Parcelable.Creator<SearchSpec!>

Creator class for SearchSpec.