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 |
Constants | |
---|---|
static Int |
Cosine similarity as metric for embedding search and ranking. |
static Int |
Use the default metric set in |
static Int |
Dot product similarity as metric for embedding search and ranking. |
static Int |
Euclidean distance as metric for embedding search and ranking. |
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 |
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 |
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 |
Int |
Returns the default embedding metric type used for embedding search (see |
MutableList<EmbeddingVector!> |
Returns the list of |
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. |
MutableList<String!> |
Returns the informational ranking expressions. |
JoinSpec? |
Returns specification on which documents need to be joined. |
Int |
Returns the maximum size of a snippet in characters. |
Int |
getOrder() 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 |
String? |
Gets a tag to indicate the source of this search, or |
MutableList<String!> |
Returns the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function. |
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 |
Constants
EMBEDDING_SEARCH_METRIC_TYPE_COSINE
static val EMBEDDING_SEARCH_METRIC_TYPE_COSINE: Int
Cosine similarity as metric for embedding search and ranking.
Value: 1
EMBEDDING_SEARCH_METRIC_TYPE_DEFAULT
static val EMBEDDING_SEARCH_METRIC_TYPE_DEFAULT: Int
Use the default metric set in SearchSpec.getDefaultEmbeddingSearchMetricType()
for embedding search and ranking.
Value: 0
EMBEDDING_SEARCH_METRIC_TYPE_DOT_PRODUCT
static val EMBEDDING_SEARCH_METRIC_TYPE_DOT_PRODUCT: Int
Dot product similarity as metric for embedding search and ranking.
Value: 2
EMBEDDING_SEARCH_METRIC_TYPE_EUCLIDEAN
static val EMBEDDING_SEARCH_METRIC_TYPE_EUCLIDEAN: Int
Euclidean distance as metric for embedding search and ranking.
Value: 3
GROUPING_TYPE_PER_NAMESPACE
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
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
static val ORDER_ASCENDING: Int
Search results will be returned in an ascending order.
Value: 1
ORDER_DESCENDING
static val ORDER_DESCENDING: Int
Search results will be returned in a descending order.
Value: 0
PROJECTION_SCHEMA_TYPE_WILDCARD
static valPROJECTION_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
static val RANKING_STRATEGY_ADVANCED_RANKING_EXPRESSION: Int
Ranked by the advanced ranking expression provided.
Value: 9
RANKING_STRATEGY_CREATION_TIMESTAMP
static val RANKING_STRATEGY_CREATION_TIMESTAMP: Int
Ranked by document creation timestamps.
Value: 2
RANKING_STRATEGY_DOCUMENT_SCORE
static val RANKING_STRATEGY_DOCUMENT_SCORE: Int
Ranked by app-provided document scores.
Value: 1
RANKING_STRATEGY_JOIN_AGGREGATE_SCORE
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
static val RANKING_STRATEGY_NONE: Int
No Ranking, results are returned in arbitrary order.
Value: 0
RANKING_STRATEGY_RELEVANCE_SCORE
static val RANKING_STRATEGY_RELEVANCE_SCORE: Int
Ranked by document relevance score.
Value: 3
RANKING_STRATEGY_SYSTEM_USAGE_COUNT
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
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
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
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
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
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
fun getAdvancedRankingExpression(): String
Get the advanced ranking expression, or "" if Builder.setRankingStrategy(String)
was not called.
Return | |
---|---|
String |
This value cannot be null . |
getDefaultEmbeddingSearchMetricType
fun getDefaultEmbeddingSearchMetricType(): Int
Returns the default embedding metric type used for embedding search (see android.app.appsearch.AppSearchSession#search
) and ranking (see android.app.appsearch.SearchSpec.Builder#setRankingStrategy(java.lang.String)
).
getEmbeddingParameters
fun getEmbeddingParameters(): MutableList<EmbeddingVector!>
Returns the list of EmbeddingVector
that can be referenced in the query through the "getEmbeddingParameter({index})" function.
Return | |
---|---|
MutableList<EmbeddingVector!> |
This value cannot be null . |
getFilterNamespaces
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
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
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 . |
getInformationalRankingExpressions
fun getInformationalRankingExpressions(): MutableList<String!>
Returns the informational ranking expressions.
Return | |
---|---|
MutableList<String!> |
This value cannot be null . |
See Also
getJoinSpec
fun getJoinSpec(): JoinSpec?
Returns specification on which documents need to be joined.
Return | |
---|---|
JoinSpec? |
This value may be null . |
getMaxSnippetSize
fun getMaxSnippetSize(): Int
Returns the maximum size of a snippet in characters.
getOrder
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
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
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
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
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 . |
getRankingStrategy
fun getRankingStrategy(): Int
Returns the ranking strategy.
getResultCountPerPage
fun getResultCountPerPage(): Int
Returns the number of results per page in the result set.
getResultGroupingLimit
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 0 if android.app.appsearch.SearchSpec.Builder#setResultGrouping(int,int) was not called. |
getResultGroupingTypeFlags
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.
getSearchStringParameters
fun getSearchStringParameters(): MutableList<String!>
Returns the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function.
Return | |
---|---|
MutableList<String!> |
This value cannot be null . |
getSnippetCount
fun getSnippetCount(): Int
Returns how many documents to generate snippets for.
getSnippetCountPerProperty
fun getSnippetCountPerProperty(): Int
Returns how many matches for each property of a matching document to generate snippets for.
getTermMatch
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
fun isListFilterQueryLanguageEnabled(): Boolean
Returns whether the LIST_FILTER_QUERY_LANGUAGE feature is enabled.
isNumericSearchEnabled
fun isNumericSearchEnabled(): Boolean
Returns whether the NUMERIC_SEARCH feature is enabled.
isVerbatimSearchEnabled
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 |