# SearchSpec

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/SearchSpec.java+class:androidx.appsearch.app.SearchSpec) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
class SearchSpec
```

<br />

*** ** * ** ***

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 types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` Builder for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec`. |

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#EMBEDDING_SEARCH_METRIC_TYPE_COSINE() = 1` Cosine similarity as metric for embedding search and ranking. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#EMBEDDING_SEARCH_METRIC_TYPE_DEFAULT() = 0` Use the default metric set in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getDefaultEmbeddingSearchMetricType()` for embedding search and ranking. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#EMBEDDING_SEARCH_METRIC_TYPE_DOT_PRODUCT() = 2` Dot product similarity as metric for embedding search and ranking. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#EMBEDDING_SEARCH_METRIC_TYPE_EUCLIDEAN() = 3` Euclidean distance as metric for embedding search and ranking. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#GROUPING_TYPE_PER_NAMESPACE() = 2` Results should be grouped together by namespace for the purpose of enforcing a limit on the number of results returned per namespace. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#GROUPING_TYPE_PER_PACKAGE() = 1` Results should be grouped together by package for the purpose of enforcing a limit on the number of results returned per package. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features.SEARCH_SPEC_GROUPING_TYPE_PER_SCHEMA) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#GROUPING_TYPE_PER_SCHEMA() = 4` Results should be grouped together by schema type for the purpose of enforcing a limit on the number of results returned per schema type. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#ORDER_ASCENDING() = 1` Search results will be returned in an ascending order. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#ORDER_DESCENDING() = 0` Search results will be returned in a descending order. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_ADVANCED_RANKING_EXPRESSION() = 9` Ranked by the advanced ranking expression provided. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_CREATION_TIMESTAMP() = 2` Ranked by document creation timestamps. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_DOCUMENT_SCORE() = 1` Ranked by app-provided document scores. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_JOIN_AGGREGATE_SCORE() = 8` Ranked by the aggregated ranking signal of the joined documents. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_NONE() = 0` No Ranking, results are returned in arbitrary order. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE() = 3` Ranked by document relevance score. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_SYSTEM_USAGE_COUNT() = 6` Ranked by number of usages from a system UI surface. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP() = 7` Ranked by timestamp of last usage from a system UI surface. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_USAGE_COUNT() = 4` Ranked by number of usages, as reported by the app. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP() = 5` Ranked by timestamp of last usage, as reported by the app. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#SCHEMA_TYPE_WILDCARD() = "*"` Schema type to be used in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterProperties(java.lang.String,java.util.Collection<java.lang.String>)` and `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjection(java.lang.String,java.util.Collection<java.lang.String>)` to apply property paths to all results, excepting any types that have had their own, specific property paths set. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#TERM_MATCH_EXACT_ONLY() = 1` Query terms will only match exact tokens in the index. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#TERM_MATCH_PREFIX() = 2` Query terms will match indexed tokens when the query term is a prefix of the token. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getAdvancedRankingExpression()()` Get the advanced ranking expression, or "" if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)` was not called. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getDefaultEmbeddingSearchMetricType()()` Returns the default embedding metric type used for embedding search (see `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)`) and ranking (see `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)`). |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getEmbeddingParameters()()` Returns the list of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector` that can be referenced in the query through the "getEmbeddingParameter({index})" function. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getEmbeddingQueryProbeCount()()` Returns the number of clusters to search for Approximate Nearest Neighbor (ANN) search. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getFilterDocumentIds()()` Returns the list of document ids to search over. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getFilterNamespaces()()` Returns the list of namespaces to search over. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getFilterPackageNames()()` Returns the list of package name filters to search over. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getFilterProperties()()` Returns the map of schema and target properties to search over. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getFilterSchemas()()` Returns the list of schema types to search for. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getInformationalRankingExpressions()()` Returns the informational ranking expressions. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec?` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getJoinSpec()()` Returns specification on which documents need to be joined. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getMaxSnippetSize()()` Returns the maximum size of a snippet in characters. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getOrder()()` Returns the order of returned search results (descending or ascending). |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!>!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getProjectionPaths()()` Returns a map from schema type to property paths to be used for projection. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getProjections()()` Returns a map from schema type to property paths to be used for projection. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html!>!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getPropertyWeightPaths()()` Returns properties weights to be used for scoring. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html!>!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getPropertyWeights()()` Returns properties weights to be used for scoring. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getRankingStrategy()()` Returns the ranking strategy. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getResultCountPerPage()()` Returns the number of results per page in the result set. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getResultGroupingLimit()()` Get the maximum number of results to return for each group. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getResultGroupingTypeFlags()()` Get the type of grouping limit to apply, or 0 if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setResultGrouping(int,int)` was not called. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getSearchSourceLogTag()()` Gets a tag to indicate the source of this search, or `null` if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setSearchSourceLogTag(java.lang.String)` was not called. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getSearchStringParameters()()` Returns the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getSnippetCount()()` Returns how many documents to generate snippets for. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getSnippetCountPerProperty()()` Returns how many matches for each property of a matching document to generate snippets for. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getTermMatch()()` Returns how the query terms should match terms in the index. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#isListFilterHasPropertyFunctionEnabled()()` Returns whether the LIST_FILTER_HAS_PROPERTY_FUNCTION feature is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#isListFilterMatchScoreExpressionFunctionEnabled()()` Returns whether the LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION feature is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#isListFilterQueryLanguageEnabled()()` Returns whether the LIST_FILTER_QUERY_LANGUAGE feature is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#isNumericSearchEnabled()()` Returns whether the NUMERIC_SEARCH feature is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#isScorablePropertyRankingEnabled()()` Returns whether the ScorablePropertyRanking feature is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#isVerbatimSearchEnabled()()` Returns whether the VERBATIM_SEARCH feature is enabled. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#shouldRetrieveEmbeddingMatchInfos()()` Returns whether to retrieve embedding match infos as a part of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getMatchInfos()` |

## Constants

### EMBEDDING_SEARCH_METRIC_TYPE_COSINE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val EMBEDDING_SEARCH_METRIC_TYPE_COSINE = 1: Int
```

Cosine similarity as metric for embedding search and ranking.

### EMBEDDING_SEARCH_METRIC_TYPE_DEFAULT

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val EMBEDDING_SEARCH_METRIC_TYPE_DEFAULT = 0: Int
```

Use the default metric set in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getDefaultEmbeddingSearchMetricType()` for embedding search and ranking.

### EMBEDDING_SEARCH_METRIC_TYPE_DOT_PRODUCT

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val EMBEDDING_SEARCH_METRIC_TYPE_DOT_PRODUCT = 2: Int
```

Dot product similarity as metric for embedding search and ranking.

### EMBEDDING_SEARCH_METRIC_TYPE_EUCLIDEAN

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val EMBEDDING_SEARCH_METRIC_TYPE_EUCLIDEAN = 3: Int
```

Euclidean distance as metric for embedding search and ranking.

### GROUPING_TYPE_PER_NAMESPACE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val GROUPING_TYPE_PER_NAMESPACE = 2: Int
```

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

### GROUPING_TYPE_PER_PACKAGE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val GROUPING_TYPE_PER_PACKAGE = 1: Int
```

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

### GROUPING_TYPE_PER_SCHEMA

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_GROUPING_TYPE_PER_SCHEMA)
const val GROUPING_TYPE_PER_SCHEMA = 4: 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.

### ORDER_ASCENDING

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val ORDER_ASCENDING = 1: Int
```

Search results will be returned in an ascending order.

### ORDER_DESCENDING

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val ORDER_DESCENDING = 0: Int
```

Search results will be returned in a descending order.

### RANKING_STRATEGY_ADVANCED_RANKING_EXPRESSION

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_ADVANCED_RANKING_EXPRESSION = 9: Int
```

Ranked by the advanced ranking expression provided.

### RANKING_STRATEGY_CREATION_TIMESTAMP

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_CREATION_TIMESTAMP = 2: Int
```

Ranked by document creation timestamps.

### RANKING_STRATEGY_DOCUMENT_SCORE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_DOCUMENT_SCORE = 1: Int
```

Ranked by app-provided document scores.

### RANKING_STRATEGY_JOIN_AGGREGATE_SCORE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_JOIN_AGGREGATE_SCORE = 8: 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 `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec` set by `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setJoinSpec(androidx.appsearch.app.JoinSpec)`. This ranking strategy may not be used if no `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec` is provided.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#build()` |   |

### RANKING_STRATEGY_NONE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_NONE = 0: Int
```

No Ranking, results are returned in arbitrary order.

### RANKING_STRATEGY_RELEVANCE_SCORE

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_RELEVANCE_SCORE = 3: Int
```

Ranked by document relevance score.

### RANKING_STRATEGY_SYSTEM_USAGE_COUNT

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_SYSTEM_USAGE_COUNT = 6: Int
```

Ranked by number of usages from a system UI surface.

### RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP = 7: Int
```

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

### RANKING_STRATEGY_USAGE_COUNT

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_USAGE_COUNT = 4: Int
```

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

### RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP = 5: Int
```

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

### SCHEMA_TYPE_WILDCARD

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val SCHEMA_TYPE_WILDCARD = "*": String!
```

Schema type to be used in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterProperties(java.lang.String,java.util.Collection<java.lang.String>)` and `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjection(java.lang.String,java.util.Collection<java.lang.String>)` to apply property paths to all results, excepting any types that have had their own, specific property paths set.

### TERM_MATCH_EXACT_ONLY

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val TERM_MATCH_EXACT_ONLY = 1: 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".

### TERM_MATCH_PREFIX

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
const val TERM_MATCH_PREFIX = 2: 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".

## Public functions

### getAdvancedRankingExpression

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getAdvancedRankingExpression(): String
```

Get the advanced ranking expression, or "" if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)` was not called.

### getDefaultEmbeddingSearchMetricType

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getDefaultEmbeddingSearchMetricType(): Int
```

Returns the default embedding metric type used for embedding search (see `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)`) and ranking (see `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)`).

### getEmbeddingParameters

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getEmbeddingParameters(): (Mutable)List<EmbeddingVector!>
```

Returns the list of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector` that can be referenced in the query through the "getEmbeddingParameter({index})" function.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)` |   |

### getEmbeddingQueryProbeCount

Added in [1.2.0-alpha02](https://developer.android.com/jetpack/androidx/releases/appsearch#1.2.0-alpha02)

```
@ExperimentalAppSearchApi
fun getEmbeddingQueryProbeCount(): Int
```

Returns the number of clusters to search for Approximate Nearest Neighbor (ANN) search.

This is used globally across all semanticSearch calls in the query expression. If this value is \<= 0, embeddings in properties marked with `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.EmbeddingPropertyConfig#INDEXING_TYPE_APPROXIMATE_NEAREST_NEIGHBOR()` will be skipped. Embeddings in properties marked with `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.EmbeddingPropertyConfig#INDEXING_TYPE_SIMILARITY()` will still be searched regardless of this value.

A larger value increases recall at the expense of higher search latency. A smaller value reduces latency but may negatively impact recall. A value of 10 is generally a good default choice.

### getFilterDocumentIds

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getFilterDocumentIds(): (Mutable)List<String!>
```

Returns the list of document ids to search over.

If empty, the query will search over all documents.

### getFilterNamespaces

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getFilterNamespaces(): (Mutable)List<String!>
```

Returns the list of namespaces to search over.

If empty, the query will search over all namespaces.

### getFilterPackageNames

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getFilterPackageNames(): (Mutable)List<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.

### getFilterProperties

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getFilterProperties(): (Mutable)Map<String!, (Mutable)List<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.

### getFilterSchemas

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getFilterSchemas(): (Mutable)List<String!>
```

Returns the list of schema types to search for.

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

### getInformationalRankingExpressions

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getInformationalRankingExpressions(): (Mutable)List<String!>
```

Returns the informational ranking expressions.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addInformationalRankingExpressions(java.lang.String...)` |   |

### getJoinSpec

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getJoinSpec(): JoinSpec?
```

Returns specification on which documents need to be joined.

### getMaxSnippetSize

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getMaxSnippetSize(): Int
```

Returns the maximum size of a snippet in characters.

### getOrder

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getOrder(): Int
```

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

### getProjectionPaths

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getProjectionPaths(): (Mutable)Map<String!, (Mutable)List<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.

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!>!>` | A mapping of schema types to lists of projection `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath` objects. |

### getProjections

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getProjections(): (Mutable)Map<String!, (Mutable)List<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.

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!>` | A mapping of schema types to lists of projection strings. |

### getPropertyWeightPaths

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getPropertyWeightPaths(): (Mutable)Map<String!, (Mutable)Map<PropertyPath!, Double!>!>
```

Returns properties weights to be used for scoring.

Calling this function repeatedly is inefficient. Prefer to retain the `https://developer.android.com/reference/java/util/Map.html` returned by this function, rather than calling it multiple times.

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html!>!>` | a `https://developer.android.com/reference/java/util/Map.html` of schema type to an inner-map of property paths of the schema type to the weight to set for that property. |

### getPropertyWeights

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getPropertyWeights(): (Mutable)Map<String!, (Mutable)Map<String!, Double!>!>
```

Returns properties weights to be used for scoring.

Calling this function repeatedly is inefficient. Prefer to retain the `https://developer.android.com/reference/java/util/Map.html` returned by this function, rather than calling it multiple times.

| Returns |
|---|---|
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html!>!>` | a `https://developer.android.com/reference/java/util/Map.html` of schema type to an inner-map of property paths of the schema type to the weight to set for that property. |

### getRankingStrategy

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getRankingStrategy(): Int
```

Returns the ranking strategy.

### getResultCountPerPage

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getResultCountPerPage(): Int
```

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

### getResultGroupingLimit

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getResultGroupingLimit(): Int
```

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

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the maximum number of results to return for each group or 0 if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setResultGrouping(int,int)` was not called. |

### getResultGroupingTypeFlags

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getResultGroupingTypeFlags(): Int
```

Get the type of grouping limit to apply, or 0 if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setResultGrouping(int,int)` was not called.

### getSearchSourceLogTag

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getSearchSourceLogTag(): String?
```

Gets a tag to indicate the source of this search, or `null` if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/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 `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setSearchSourceLogTag(java.lang.String)` 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

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getSearchStringParameters(): (Mutable)List<String!>
```

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

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)` |   |

### getSnippetCount

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getSnippetCount(): Int
```

Returns how many documents to generate snippets for.

### getSnippetCountPerProperty

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getSnippetCountPerProperty(): Int
```

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

### getTermMatch

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getTermMatch(): Int
```

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

### isListFilterHasPropertyFunctionEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun isListFilterHasPropertyFunctionEnabled(): Boolean
```

Returns whether the LIST_FILTER_HAS_PROPERTY_FUNCTION feature is enabled.

### isListFilterMatchScoreExpressionFunctionEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@ExperimentalAppSearchApi
fun isListFilterMatchScoreExpressionFunctionEnabled(): Boolean
```

Returns whether the LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION feature is enabled.

### isListFilterQueryLanguageEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun isListFilterQueryLanguageEnabled(): Boolean
```

Returns whether the LIST_FILTER_QUERY_LANGUAGE feature is enabled.

### isNumericSearchEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun isNumericSearchEnabled(): Boolean
```

Returns whether the NUMERIC_SEARCH feature is enabled.

### isScorablePropertyRankingEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@ExperimentalAppSearchApi
fun isScorablePropertyRankingEnabled(): Boolean
```

Returns whether the ScorablePropertyRanking feature is enabled.

### isVerbatimSearchEnabled

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun isVerbatimSearchEnabled(): Boolean
```

Returns whether the VERBATIM_SEARCH feature is enabled.

### shouldRetrieveEmbeddingMatchInfos

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
@ExperimentalAppSearchApi
fun shouldRetrieveEmbeddingMatchInfos(): Boolean
```

Returns whether to retrieve embedding match infos as a part of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getMatchInfos()`