# SearchSpec.Builder

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.Builder) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
class SearchSpec.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#Builder()()` Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` objects. |
| `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#Builder(androidx.appsearch.app.SearchSpec)(searchSpec: https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec)` Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` from the given `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.SCHEMA_EMBEDDING_PROPERTY_CONFIG) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addEmbeddingParameters(androidx.appsearch.app.EmbeddingVector...)(searchEmbeddings: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector!>)` Adds an embedding search to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry, which will be referred in the query expression and the ranking expression for embedding search. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.SCHEMA_EMBEDDING_PROPERTY_CONFIG) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addEmbeddingParameters(java.util.Collection<androidx.appsearch.app.EmbeddingVector>)( searchEmbeddings: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector!> )` Adds an embedding search to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry, which will be referred in the query expression and the ranking expression for embedding search. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterDocumentClasses(java.lang.Class<?>...)(documentClasses: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/lang/Class.html<*>!>)` Adds the Schema names of given document classes to the Schema type filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterDocumentClasses(java.util.Collection<? extends java.lang.Class<?>>)( documentClasses: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/java/lang/Class.html<*>!> )` Adds the Schema names of given document classes to the Schema type filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_FILTER_DOCUMENT_IDS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterDocumentIds(java.lang.String...)(documentIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a document id filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_FILTER_DOCUMENT_IDS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterDocumentIds(java.util.Collection<java.lang.String>)(documentIds: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a document id filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterNamespaces(java.lang.String...)(namespaces: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a namespace filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterNamespaces(java.util.Collection<java.lang.String>)(namespaces: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a namespace filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterPackageNames(java.lang.String...)(packageNames: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a package name filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterPackageNames(java.util.Collection<java.lang.String>)(packageNames: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a package name filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_FILTER_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterProperties(java.lang.Class<?>,java.util.Collection<java.lang.String>)( documentClass: https://developer.android.com/reference/java/lang/Class.html<*>, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_FILTER_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterProperties(java.lang.String,java.util.Collection<java.lang.String>)( schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_FILTER_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterPropertyPaths(java.lang.Class<?>,java.util.Collection<androidx.appsearch.app.PropertyPath>)( documentClass: https://developer.android.com/reference/java/lang/Class.html<*>, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!> )` Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_FILTER_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterPropertyPaths(java.lang.String,java.util.Collection<androidx.appsearch.app.PropertyPath>)( schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!> )` Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterSchemas(java.lang.String...)(schemas: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a Schema type filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterSchemas(java.util.Collection<java.lang.String>)(schemas: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds a Schema type filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_INFORMATIONAL_RANKING_EXPRESSIONS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addInformationalRankingExpressions(java.lang.String...)( informationalRankingExpressions: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Adds informational ranking expressions to be evaluated for each document in the search result. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADD_INFORMATIONAL_RANKING_EXPRESSIONS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addInformationalRankingExpressions(java.util.Collection<java.lang.String>)( informationalRankingExpressions: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Adds informational ranking expressions to be evaluated for each document in the search result. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjection(java.lang.String,java.util.Collection<java.lang.String>)(schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds property paths for the specified type to be used for projection. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjectionPaths(java.lang.String,java.util.Collection<androidx.appsearch.app.PropertyPath>)( schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!> )` Adds property paths for the specified type to be used for projection. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjectionPathsForDocumentClass(java.lang.Class<?>,java.util.Collection<androidx.appsearch.app.PropertyPath>)( documentClass: https://developer.android.com/reference/java/lang/Class.html<*>, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!> )` Adds property paths for the specified Document class to be used for projection. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjectionsForDocumentClass(java.lang.Class<?>,java.util.Collection<java.lang.String>)( documentClass: https://developer.android.com/reference/java/lang/Class.html<*>, propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Adds property paths for the Document class to be used for projection. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_SEARCH_STRING_PARAMETERS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addSearchStringParameters(java.lang.String...)(searchStringParameters: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds Strings to the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_SEARCH_STRING_PARAMETERS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addSearchStringParameters(java.util.List<java.lang.String>)( searchStringParameters: (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!> )` Adds Strings to the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#build()()` Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` from the contents of this builder. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearEmbeddingParameters()()` Clears the embedding parameters. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearFilterDocumentIds()()` Clears the document id filters. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearFilterNamespaces()()` Clears all namespace filters. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearFilterPackageNames()()` Clears all package name filters. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearFilterProperties()()` Clears the property filters for all schema types. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearFilterSchemas()()` Clears all schema type filters. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearInformationalRankingExpressions()()` Clears all informational ranking expressions. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearJoinSpec()()` Clears the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearProjections()()` Clears the projections for all schema types. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearPropertyWeights()()` Clears the property weights for all schema types. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearResultGrouping()()` Clears the result grouping and limit. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearSearchSourceLogTag()()` Clears the log tag that indicates the source of this search. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#clearSearchStringParameters()()` Clears the list of String parameters that can be referenced in the query through the "getSearchStringParameter({index})" function. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.SCHEMA_EMBEDDING_PROPERTY_CONFIG) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setDefaultEmbeddingSearchMetricType(int)( defaultEmbeddingSearchMetricType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets 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://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.SCHEMA_EMBEDDING_APPROXIMATE_NEAREST_NEIGHBOR) @https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setEmbeddingQueryProbeCount(int)(embeddingQueryProbeCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the number of clusters to search for Approximate Nearest Neighbor (ANN) search. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.JOIN_SPEC_AND_QUALIFIED_ID) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setJoinSpec(androidx.appsearch.app.JoinSpec)(joinSpec: https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec)` Specifies which documents to join with, and how to join. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.LIST_FILTER_HAS_PROPERTY_FUNCTION) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setListFilterHasPropertyFunctionEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets the LIST_FILTER_HAS_PROPERTY_FUNCTION feature as enabled/disabled according to the enabled parameter. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION) @https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setListFilterMatchScoreExpressionFunctionEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets the LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION feature as enabled/disabled according to the enabled parameter. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.LIST_FILTER_QUERY_LANGUAGE) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setListFilterQueryLanguageEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets the LIST_FILTER_QUERY_LANGUAGE feature as enabled/disabled according to the enabled parameter. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setMaxSnippetSize(int)(maxSnippetSize: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 10000) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets `maxSnippetSize`, the maximum snippet size. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.NUMERIC_SEARCH) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setNumericSearchEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets the NUMERIC_SEARCH feature as enabled/disabled according to the enabled parameter. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setOrder(int)(order: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the order of returned search results, the default is `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#ORDER_DESCENDING()`, meaning that results with higher scores come first. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_PROPERTY_WEIGHTS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setPropertyWeightPaths(java.lang.String,java.util.Map<androidx.appsearch.app.PropertyPath,java.lang.Double>)( schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, propertyPathWeights: (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!> )` Sets property weights by schema type and property path. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_PROPERTY_WEIGHTS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setPropertyWeightPathsForDocumentClass(java.lang.Class<?>,java.util.Map<androidx.appsearch.app.PropertyPath,java.lang.Double>)( documentClass: https://developer.android.com/reference/java/lang/Class.html<*>, propertyPathWeights: (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!> )` Sets property weights by schema type and property path. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_PROPERTY_WEIGHTS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setPropertyWeights(java.lang.String,java.util.Map<java.lang.String,java.lang.Double>)( schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, propertyPathWeights: (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!> )` Sets property weights by schema type and property path. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_PROPERTY_WEIGHTS) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setPropertyWeightsForDocumentClass(java.lang.Class<?>,java.util.Map<java.lang.String,java.lang.Double>)( documentClass: https://developer.android.com/reference/java/lang/Class.html<*>, propertyPathWeights: (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!> )` Sets property weights by schema type and property path. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_ADVANCED_RANKING_EXPRESSION) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)(advancedRankingExpression: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Enables advanced ranking to score based on `advancedRankingExpression`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(int)(rankingStrategy: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets ranking strategy for AppSearch results. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setResultCountPerPage(int)( resultCountPerPage: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 10000) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets the number of results per page in the returned object. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setResultGrouping(int,int)(groupingTypeFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the maximum number of results to return for each group, where groups are defined by grouping type. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_EMBEDDING_MATCH_INFO) @https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRetrieveEmbeddingMatchInfos(boolean)(retrieveEmbeddingMatchInfos: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets whether to retrieve embedding match infos as a part of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getMatchInfos()`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.SCHEMA_SCORABLE_PROPERTY_CONFIG) @https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setScorablePropertyRankingEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets the ScorablePropertyRanking feature as enabled or disabled. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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_SET_SEARCH_SOURCE_LOG_TAG) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setSearchSourceLogTag(java.lang.String)(searchSourceLogTag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets an optional log tag to indicate the source of this search. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setSnippetCount(int)(snippetCount: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 10000) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the `snippetCount` such that the first `snippetCount` documents based on the ranking strategy will have snippet information provided. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setSnippetCountPerProperty(int)( snippetCountPerProperty: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = 10000) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` Sets `snippetCountPerProperty`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setTermMatch(int)(termMatchType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets how the query terms should match `TermMatchCode` in the index. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` | `@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.VERBATIM_SEARCH) https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setVerbatimSearchEnabled(boolean)(enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Sets the VERBATIM_SEARCH feature as enabled/disabled according to the enabled parameter. |

## Public constructors

### Builder

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

```
Builder()
```

Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` objects.

### Builder

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

```
@ExperimentalAppSearchApi
Builder(searchSpec: SearchSpec)
```

Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder` from the given `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec`.

## Public functions

### addEmbeddingParameters

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_EMBEDDING_PROPERTY_CONFIG)
fun addEmbeddingParameters(searchEmbeddings: Array<EmbeddingVector!>): SearchSpec.Builder
```

Adds an embedding search to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry, which will be referred in the query expression and the ranking expression for embedding search.

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

### addEmbeddingParameters

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.SCHEMA_EMBEDDING_PROPERTY_CONFIG)
fun addEmbeddingParameters(
    searchEmbeddings: (Mutable)Collection<EmbeddingVector!>
): SearchSpec.Builder
```

Adds an embedding search to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry, which will be referred in the query expression and the ranking expression for embedding search.

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

### addFilterDocumentClasses

```
fun addFilterDocumentClasses(documentClasses: Array<Class<*>!>): SearchSpec.Builder
```

Adds the Schema names of given document classes to the Schema type filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified schema types.

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

Merged list available from `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getFilterSchemas()`.

| Parameters |
|---|---|
| `documentClasses: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/java/lang/Class.html<*>!>` | classes annotated with `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` |   |

### addFilterDocumentClasses

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

```
fun addFilterDocumentClasses(
    documentClasses: (Mutable)Collection<Class<*>!>
): SearchSpec.Builder
```

Adds the Schema names of given document classes to the Schema type filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified schema types.

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

Merged list available from `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getFilterSchemas()`.

| Parameters |
|---|---|
| `documentClasses: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/java/lang/Class.html<*>!>` | classes annotated with `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` |   |

### addFilterDocumentIds

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_FILTER_DOCUMENT_IDS)
fun addFilterDocumentIds(documentIds: Array<String!>): SearchSpec.Builder
```

Adds a document id filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified document ids.

If unset, the query will search over all documents.

### addFilterDocumentIds

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_ADD_FILTER_DOCUMENT_IDS)
fun addFilterDocumentIds(documentIds: (Mutable)Collection<String!>): SearchSpec.Builder
```

Adds a document id filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified document ids.

If unset, the query will search over all documents.

### addFilterNamespaces

```
fun addFilterNamespaces(namespaces: Array<String!>): SearchSpec.Builder
```

Adds a namespace filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified namespaces.

If unset, the query will search over all namespaces.

### addFilterNamespaces

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

```
fun addFilterNamespaces(namespaces: (Mutable)Collection<String!>): SearchSpec.Builder
```

Adds a namespace filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified namespaces.

If unset, the query will search over all namespaces.

### addFilterPackageNames

```
fun addFilterPackageNames(packageNames: Array<String!>): SearchSpec.Builder
```

Adds a package name filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that were indexed from the specified packages.

If unset, 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.

### addFilterPackageNames

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

```
fun addFilterPackageNames(packageNames: (Mutable)Collection<String!>): SearchSpec.Builder
```

Adds a package name filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that were indexed from the specified packages.

If unset, 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.

### addFilterProperties

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_ADD_FILTER_PROPERTIES)
fun addFilterProperties(
    documentClass: Class<*>,
    propertyPaths: (Mutable)Collection<String!>
): SearchSpec.Builder
```

Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only returns documents that have matches under the specified properties. If property paths are added for a type, then only the properties referred to will be searched for results of that type.

| Parameters |
|---|---|
| `documentClass: https://developer.android.com/reference/java/lang/Class.html<*>` | class annotated with `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document`. |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | The String version of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath`. A dot-delimitedsequence of property names. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterProperties(java.lang.String,java.util.Collection<java.lang.String>)` |   |

### addFilterProperties

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_ADD_FILTER_PROPERTIES)
fun addFilterProperties(
    schema: String,
    propertyPaths: (Mutable)Collection<String!>
): SearchSpec.Builder
```

Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only returns documents that have matches under the specified properties. If property paths are added for a type, then only the properties referred to will be searched for results of that type.

If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

If no property paths are added for a particular type, then all properties of results of that type will be searched.

Example properties: 'body', 'sender.name', 'sender.emailaddress', etc.

If property paths are added for the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#SCHEMA_TYPE_WILDCARD()`, then those property paths will apply to all results, excepting any types that have their own, specific property paths set.

| Parameters |
|---|---|
| `schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` that contains the target properties |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | The String version of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath`. A dot-delimited sequence of property names. |

### addFilterPropertyPaths

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_ADD_FILTER_PROPERTIES)
fun addFilterPropertyPaths(
    documentClass: Class<*>,
    propertyPaths: (Mutable)Collection<PropertyPath!>
): SearchSpec.Builder
```

Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only returns documents that have matches under the specified properties. If property paths are added for a type, then only the properties referred to will be searched for results of that type.

| Parameters |
|---|---|
| `documentClass: https://developer.android.com/reference/java/lang/Class.html<*>` | class annotated with `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document`. |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!>` | The `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath` to search search over |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterProperties(java.lang.String,java.util.Collection<java.lang.String>)` |   |

### addFilterPropertyPaths

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_ADD_FILTER_PROPERTIES)
fun addFilterPropertyPaths(
    schema: String,
    propertyPaths: (Mutable)Collection<PropertyPath!>
): SearchSpec.Builder
```

Adds property paths for the specified type to the property filter of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only returns documents that have matches under the specified properties. If property paths are added for a type, then only the properties referred to will be searched for results of that type.

| Parameters |
|---|---|
| `schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` that contains the target properties |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!>` | The `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath` to search search over |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addFilterProperties(java.lang.String,java.util.Collection<java.lang.String>)` |   |

### addFilterSchemas

```
fun addFilterSchemas(schemas: Array<String!>): SearchSpec.Builder
```

Adds a Schema type filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified schema types.

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

### addFilterSchemas

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

```
fun addFilterSchemas(schemas: (Mutable)Collection<String!>): SearchSpec.Builder
```

Adds a Schema type filter to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` Entry. Only search for documents that have the specified schema types.

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

### addInformationalRankingExpressions

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_ADD_INFORMATIONAL_RANKING_EXPRESSIONS)
fun addInformationalRankingExpressions(
    informationalRankingExpressions: Array<String!>
): SearchSpec.Builder
```

Adds informational ranking expressions to be evaluated for each document in the search result. The values of these expressions will be returned to the caller via `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getInformationalRankingSignals()`. These expressions are purely for the caller to retrieve additional information about the result and have no effect on ranking.

The syntax is exactly the same as specified in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)`.

### addInformationalRankingExpressions

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_ADD_INFORMATIONAL_RANKING_EXPRESSIONS)
fun addInformationalRankingExpressions(
    informationalRankingExpressions: (Mutable)Collection<String!>
): SearchSpec.Builder
```

Adds informational ranking expressions to be evaluated for each document in the search result. The values of these expressions will be returned to the caller via `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getInformationalRankingSignals()`. These expressions are purely for the caller to retrieve additional information about the result and have no effect on ranking.

The syntax is exactly the same as specified in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)`.

### addProjection

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

```
fun addProjection(schema: String, propertyPaths: (Mutable)Collection<String!>): SearchSpec.Builder
```

Adds property paths for the specified type to be used for projection. If property paths are added for a type, then only the properties referred to will be retrieved for results of that type. If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

| Parameters |
|---|---|
| `schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | a string corresponding to the schema to add projections to. |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | the projections to add. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjectionPaths(java.lang.String,java.util.Collection<androidx.appsearch.app.PropertyPath>)` |   |

### addProjectionPaths

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

```
fun addProjectionPaths(
    schema: String,
    propertyPaths: (Mutable)Collection<PropertyPath!>
): SearchSpec.Builder
```

Adds property paths for the specified type to be used for projection. If property paths are added for a type, then only the properties referred to will be retrieved for results of that type. If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

If no property paths are added for a particular type, then all properties of results of that type will be retrieved.

If property path is added for the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#SCHEMA_TYPE_WILDCARD()`, then those property paths will apply to all results, excepting any types that have their own, specific property paths set.

Suppose the following document is in the index.

```kotlin
Email: Document {
  sender: Document {
    name: "Mr. Person"
    email: "mrperson123@google.com"
  }
  recipients: [
    Document {
      name: "John Doe"
      email: "johndoe123@google.com"
    }
    Document {
      name: "Jane Doe"
      email: "janedoe123@google.com"
    }
  ]
  subject: "IMPORTANT"
  body: "Limited time offer!"
}
```

Then, suppose that a query for "important" is issued with the following projection type property paths:

```kotlin
{schema: "Email", ["subject", "sender.name", "recipients.name"]}
```

The above document will be returned as:

```kotlin
Email: Document {
  sender: Document {
    name: "Mr. Body"
  }
  recipients: [
    Document {
      name: "John Doe"
    }
    Document {
      name: "Jane Doe"
    }
  ]
  subject: "IMPORTANT"
}
```

| Parameters |
|---|---|
| `schema: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | a string corresponding to the schema to add projections to. |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!>` | the projections to add. |

### addProjectionPathsForDocumentClass

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

```
fun addProjectionPathsForDocumentClass(
    documentClass: Class<*>,
    propertyPaths: (Mutable)Collection<PropertyPath!>
): SearchSpec.Builder
```

Adds property paths for the specified Document class to be used for projection.

| Parameters |
|---|---|
| `documentClass: https://developer.android.com/reference/java/lang/Class.html<*>` | a class, annotated with @Document, corresponding to the schema to add projections to. |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!>` | the projections to add. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjectionPaths(java.lang.String,java.util.Collection<androidx.appsearch.app.PropertyPath>)` |   |

### addProjectionsForDocumentClass

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

```
fun addProjectionsForDocumentClass(
    documentClass: Class<*>,
    propertyPaths: (Mutable)Collection<String!>
): SearchSpec.Builder
```

Adds property paths for the Document class to be used for projection. If property paths are added for a document class, then only the properties referred to will be retrieved for results of that type. If a property path that is specified isn't present in a result, it will be ignored for that result. Property paths cannot be null.

| Parameters |
|---|---|
| `documentClass: https://developer.android.com/reference/java/lang/Class.html<*>` | a class, annotated with @Document, corresponding to the schema to add projections to. |
| `propertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | the projections to add. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#addProjection(java.lang.String,java.util.Collection<java.lang.String>)` |   |

### addSearchStringParameters

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SEARCH_SPEC_SEARCH_STRING_PARAMETERS)
fun addSearchStringParameters(searchStringParameters: Array<String!>): SearchSpec.Builder
```

Adds Strings to 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)` |   |

### addSearchStringParameters

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_SEARCH_STRING_PARAMETERS)
fun addSearchStringParameters(
    searchStringParameters: (Mutable)List<String!>
): SearchSpec.Builder
```

Adds Strings to 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)` |   |

### build

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

```
fun build(): SearchSpec
```

Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec` from the contents of this builder.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if property weights are provided with a ranking strategy that isn't RANKING_STRATEGY_RELEVANCE_SCORE. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the ranking strategy is `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_JOIN_AGGREGATE_SCORE()` and `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setJoinSpec(androidx.appsearch.app.JoinSpec)` has never been called. |
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if the aggregation scoring strategy has been set in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec#getAggregationScoringStrategy()` but the ranking strategy is not `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_JOIN_AGGREGATE_SCORE()`. |

### clearEmbeddingParameters

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

```
@ExperimentalAppSearchApi
fun clearEmbeddingParameters(): SearchSpec.Builder
```

Clears the embedding parameters.

### clearFilterDocumentIds

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

```
fun clearFilterDocumentIds(): SearchSpec.Builder
```

Clears the document id filters.

### clearFilterNamespaces

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

```
@ExperimentalAppSearchApi
fun clearFilterNamespaces(): SearchSpec.Builder
```

Clears all namespace filters.

### clearFilterPackageNames

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

```
@ExperimentalAppSearchApi
fun clearFilterPackageNames(): SearchSpec.Builder
```

Clears all package name filters.

### clearFilterProperties

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

```
@ExperimentalAppSearchApi
fun clearFilterProperties(): SearchSpec.Builder
```

Clears the property filters for all schema types.

### clearFilterSchemas

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

```
@ExperimentalAppSearchApi
fun clearFilterSchemas(): SearchSpec.Builder
```

Clears all schema type filters.

### clearInformationalRankingExpressions

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

```
@ExperimentalAppSearchApi
fun clearInformationalRankingExpressions(): SearchSpec.Builder
```

Clears all informational ranking expressions.

### clearJoinSpec

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

```
@ExperimentalAppSearchApi
fun clearJoinSpec(): SearchSpec.Builder
```

Clears the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec`.

### clearProjections

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

```
@ExperimentalAppSearchApi
fun clearProjections(): SearchSpec.Builder
```

Clears the projections for all schema types.

### clearPropertyWeights

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

```
@ExperimentalAppSearchApi
fun clearPropertyWeights(): SearchSpec.Builder
```

Clears the property weights for all schema types.

### clearResultGrouping

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

```
@ExperimentalAppSearchApi
fun clearResultGrouping(): SearchSpec.Builder
```

Clears the result grouping and limit.

### clearSearchSourceLogTag

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

```
@ExperimentalAppSearchApi
fun clearSearchSourceLogTag(): SearchSpec.Builder
```

Clears the log tag that indicates the source of this search.

### clearSearchStringParameters

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

```
@ExperimentalAppSearchApi
fun clearSearchStringParameters(): SearchSpec.Builder
```

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

### setDefaultEmbeddingSearchMetricType

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.SCHEMA_EMBEDDING_PROPERTY_CONFIG)
fun setDefaultEmbeddingSearchMetricType(
    defaultEmbeddingSearchMetricType: Int
): SearchSpec.Builder
```

Sets 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)`).

If this method is not called, the default embedding search metric type is `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#EMBEDDING_SEARCH_METRIC_TYPE_COSINE()`. Metrics specified within "semanticSearch" or "matchedSemanticScores" functions in search/ranking expressions will override this default.

### setEmbeddingQueryProbeCount

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

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_EMBEDDING_APPROXIMATE_NEAREST_NEIGHBOR)
@ExperimentalAppSearchApi
fun setEmbeddingQueryProbeCount(embeddingQueryProbeCount: Int): SearchSpec.Builder
```

Sets 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.

If this method is not called, the default value is 10.

### setJoinSpec

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.JOIN_SPEC_AND_QUALIFIED_ID)
fun setJoinSpec(joinSpec: JoinSpec): SearchSpec.Builder
```

Specifies which documents to join with, and how to join.

If the ranking strategy is `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_JOIN_AGGREGATE_SCORE()`, and the JoinSpec is null, `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#build()` will throw an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException`.

| Parameters |
|---|---|
| `joinSpec: https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec` | a specification on how to perform the Join operation. |

### setListFilterHasPropertyFunctionEnabled

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.LIST_FILTER_HAS_PROPERTY_FUNCTION)
fun setListFilterHasPropertyFunctionEnabled(enabled: Boolean): SearchSpec.Builder
```

Sets the LIST_FILTER_HAS_PROPERTY_FUNCTION feature as enabled/disabled according to the enabled parameter.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Enables the feature if true, otherwise disables it If disabled, disallows the use of the "hasProperty" function. See `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)` for more details about the function. |

### setListFilterMatchScoreExpressionFunctionEnabled

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.LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION)
@ExperimentalAppSearchApi
fun setListFilterMatchScoreExpressionFunctionEnabled(enabled: Boolean): SearchSpec.Builder
```

Sets the LIST_FILTER_MATCH_SCORE_EXPRESSION_FUNCTION feature as enabled/disabled according to the enabled parameter.

If not enabled, the use of the "matchScoreExpression" function is disallowed. See `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)` for more details about the function.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Enables the feature if true, otherwise disables it |

### setListFilterQueryLanguageEnabled

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.LIST_FILTER_QUERY_LANGUAGE)
fun setListFilterQueryLanguageEnabled(enabled: Boolean): SearchSpec.Builder
```

Sets the LIST_FILTER_QUERY_LANGUAGE feature as enabled/disabled according to the enabled parameter.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Enables the feature if true, otherwise disables it. This feature covers the expansion of the query language to conform to the definition of the list filters language (https://aip.dev/160). This includes: - addition of explicit 'AND' and 'NOT' operators - property restricts are allowed with grouping (ex. "prop:(a OR b)") - addition of custom functions to control matching The newly added custom functions covered by this feature are: - createList(String...) - termSearch(String, `List<String>`) createList takes a variable number of strings and returns a list of strings. It is for use with termSearch. termSearch takes a query string that will be parsed according to the supported query language and an optional list of strings that specify the properties to be restricted to. This exists as a convenience for multiple property restricts. So, for example, the query "(subject:foo OR body:foo) (subject:bar OR body:bar)" could be rewritten as "termSearch(\\"foo bar\\", createList(\\"subject\\", \\"bar\\"))" |

### setMaxSnippetSize

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

```
fun setMaxSnippetSize(maxSnippetSize: @IntRange(from = 0, to = 10000) Int): SearchSpec.Builder
```

Sets `maxSnippetSize`, the maximum snippet size. Snippet windows start at `maxSnippetSize/2` bytes before the middle of the matching token and end at `maxSnippetSize/2` bytes after the middle of the matching token. It respects token boundaries, therefore the returned window may be smaller than requested.

Setting `maxSnippetSize` to 0 will disable windowing and an empty String will be returned. If matches enabled is also set to false, then snippeting is disabled.

For example, `maxSnippetSize` = 16. "foo bar baz bat rat" with a query of "baz" will return a window of "bar baz bat" which is only 11 bytes long.

### setNumericSearchEnabled

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.NUMERIC_SEARCH)
fun setNumericSearchEnabled(enabled: Boolean): SearchSpec.Builder
```

Sets the NUMERIC_SEARCH feature as enabled/disabled according to the enabled parameter.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Enables the feature if true, otherwise disables it. If disabled, disallows use of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.LongPropertyConfig#INDEXING_TYPE_RANGE()` and all other numeric querying features. |

### setOrder

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

```
fun setOrder(order: Int): SearchSpec.Builder
```

Sets the order of returned search results, the default is `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#ORDER_DESCENDING()`, meaning that results with higher scores come first.

This order field will be ignored if RankingStrategy = `RANKING_STRATEGY_NONE`.

### setPropertyWeightPaths

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_PROPERTY_WEIGHTS)
fun setPropertyWeightPaths(
    schemaType: String,
    propertyPathWeights: (Mutable)Map<PropertyPath!, Double!>
): SearchSpec.Builder
```

Sets property weights by schema type and property path.

Property weights are used to promote and demote query term matches within a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` property when applying scoring.

Property weights must be positive values (greater than 0). A property's weight is multiplied with that property's scoring contribution. This means weights set between 0.0 and 1.0 demote scoring contributions by a term match within the property. Weights set above 1.0 promote scoring contributions by a term match within the property.

Properties that exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema`, but do not have a weight explicitly set will be given a default weight of 1.0.

Weights set for property paths that do not exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` will be discarded and not affect scoring.

**NOTE:** Property weights only affect scoring for query-dependent scoring strategies, such as `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE()`.

This information may not be available depending on the backend and Android API level. To ensure it is available, call `https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the schema type to set property weights for. |
| `propertyPathWeights: (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 property paths of the schema type to the weight to set for that property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if a weight is equal to or less than 0.0. |

### setPropertyWeightPathsForDocumentClass

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_PROPERTY_WEIGHTS)
fun setPropertyWeightPathsForDocumentClass(
    documentClass: Class<*>,
    propertyPathWeights: (Mutable)Map<PropertyPath!, Double!>
): SearchSpec.Builder
```

Sets property weights by schema type and property path.

Property weights are used to promote and demote query term matches within a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` property when applying scoring.

Property weights must be positive values (greater than 0). A property's weight is multiplied with that property's scoring contribution. This means weights set between 0.0 and 1.0 demote scoring contributions by a term match within the property. Weights set above 1.0 promote scoring contributions by a term match within the property.

Properties that exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema`, but do not have a weight explicitly set will be given a default weight of 1.0.

Weights set for property paths that do not exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` will be discarded and not affect scoring.

**NOTE:** Property weights only affect scoring for query-dependent scoring strategies, such as `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE()`.

This information may not be available depending on the backend and Android API level. To ensure it is available, call `https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `documentClass: https://developer.android.com/reference/java/lang/Class.html<*>` | a class, annotated with @Document, corresponding to the schema to set property weights for. |
| `propertyPathWeights: (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 property paths of the schema type to the weight to set for that property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` | if no factory for this document class could be found on the classpath |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if a weight is equal to or less than 0.0. |

### setPropertyWeights

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_PROPERTY_WEIGHTS)
fun setPropertyWeights(
    schemaType: String,
    propertyPathWeights: (Mutable)Map<String!, Double!>
): SearchSpec.Builder
```

Sets property weights by schema type and property path.

Property weights are used to promote and demote query term matches within a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` property when applying scoring.

Property weights must be positive values (greater than 0). A property's weight is multiplied with that property's scoring contribution. This means weights set between 0.0 and 1.0 demote scoring contributions by a term match within the property. Weights set above 1.0 promote scoring contributions by a term match within the property.

Properties that exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema`, but do not have a weight explicitly set will be given a default weight of 1.0.

Weights set for property paths that do not exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` will be discarded and not affect scoring.

**NOTE:** Property weights only affect scoring for query-dependent scoring strategies, such as `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE()`.

This information may not be available depending on the backend and Android API level. To ensure it is available, call `https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the schema type to set property weights for. |
| `propertyPathWeights: (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 property paths of the schema type to the weight to set for that property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if a weight is equal to or less than 0.0. |

### setPropertyWeightsForDocumentClass

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_PROPERTY_WEIGHTS)
fun setPropertyWeightsForDocumentClass(
    documentClass: Class<*>,
    propertyPathWeights: (Mutable)Map<String!, Double!>
): SearchSpec.Builder
```

Sets property weights by schema type and property path.

Property weights are used to promote and demote query term matches within a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` property when applying scoring.

Property weights must be positive values (greater than 0). A property's weight is multiplied with that property's scoring contribution. This means weights set between 0.0 and 1.0 demote scoring contributions by a term match within the property. Weights set above 1.0 promote scoring contributions by a term match within the property.

Properties that exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema`, but do not have a weight explicitly set will be given a default weight of 1.0.

Weights set for property paths that do not exist in the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` will be discarded and not affect scoring.

**NOTE:** Property weights only affect scoring for query-dependent scoring strategies, such as `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE()`.

This information may not be available depending on the backend and Android API level. To ensure it is available, call `https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features#isFeatureSupported(java.lang.String)`.

| Parameters |
|---|---|
| `documentClass: https://developer.android.com/reference/java/lang/Class.html<*>` | a class, annotated with @Document, corresponding to the schema to set property weights for. |
| `propertyPathWeights: (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 property paths of the schema type to the weight to set for that property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` | if no factory for this document class could be found on the classpath |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if a weight is equal to or less than 0.0. |

### setRankingStrategy

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_ADVANCED_RANKING_EXPRESSION)
fun setRankingStrategy(advancedRankingExpression: String): SearchSpec.Builder
```

Enables advanced ranking to score based on `advancedRankingExpression`.

This method will set RankingStrategy to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_ADVANCED_RANKING_EXPRESSION()`.

The ranking expression is a mathematical expression that will be evaluated to a floating-point number of double type representing the score of each document.

Numeric literals, arithmetic operators, mathematical functions, document-based, and property-value-based functions are supported to build expressions.

The following are supported arithmetic operators:

- Addition(+)
- Subtraction(-)
- Multiplication(\*)
- Floating Point Division(/)

Operator precedences are compliant with the Java Language, and parentheses are supported. For example, "2.2 + (3 - 4) / 2" evaluates to 1.7.

The following are supported basic mathematical functions:

- log(x) - the natural log of x
- log(x, y) - the log of y with base x
- pow(x, y) - x to the power of y
- sqrt(x)
- abs(x)
- sin(x), cos(x), tan(x)
- Example: "max(abs(-100), 10) + pow(2, 10)" will be evaluated to 1124

The following variadic mathematical functions are supported, with n \>0. They also accept list value parameters. For example, if V is a value of list type, we can call sum(V) to get the sum of all the values in V. List literals are not supported, so a value of list type can only be constructed as a return value of some particular document-based functions.

- max(v1, v2, ..., vn) or max(V)
- min(v1, v2, ..., vn) or min(V)
- len(v1, v2, ..., vn) or len(V)
- sum(v1, v2, ..., vn) or sum(V)
- avg(v1, v2, ..., vn) or avg(V)

Document-based functions must be called via "this", which represents the current document being scored. The following are supported document-based functions:

- this.documentScore() Get the app-provided document score of the current document. This is the same score that is returned for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_DOCUMENT_SCORE()`.

- this.creationTimestamp() Get the creation timestamp of the current document. This is the same score that is returned for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_CREATION_TIMESTAMP()`.

- this.relevanceScore() Get the BM25F relevance score of the current document in relation to the query string. This is the same score that is returned for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE()`.

- this.usageCount(type) and this.usageLastUsedTimestamp(type) Get the number of usages or the timestamp of last usage by type for the current document, where type must be evaluated to an integer from 1 to 2. Type 1 refers to usages reported by `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#reportUsageAsync(androidx.appsearch.app.ReportUsageRequest)`, and type 2 refers to usages reported by `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GlobalSearchSession#reportSystemUsageAsync(androidx.appsearch.app.ReportSystemUsageRequest)`.

- this.childrenRankingSignals() Returns a list of children ranking signals calculated by scoring the joined documents using the ranking strategy specified in the nested `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec`. Currently, a document can only be a child of another document in the context of joins. If this function is called without the Join API enabled, a type error will be raised.

- this.propertyWeights() Returns a list of the normalized weights of the matched properties for the current document being scored. Property weights come from what's specified in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec`. After normalizing, each provided weight will be divided by the maximum weight, so that each of them will be \<= 1.

- this.matchedSemanticScores(getEmbeddingParameter({embedding_index}), {metric}) Returns a list of the matched similarity scores from "semanticSearch" in the query expression (see also `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)`) based on embedding_index and metric. If metric is omitted, it defaults to the metric specified in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setDefaultEmbeddingSearchMetricType(int)`. If no "semanticSearch" is called for embedding_index and metric in the query, this function will return an empty list. If multiple "semanticSearch"s are called for the same embedding_index and metric, this function will return a list of their merged scores.

  Example: \`this.matchedSemanticScores(getEmbeddingParameter(0), "COSINE")\` will return a list of matched scores within the range of \[0.5, 1\], if \`semanticSearch(getEmbeddingParameter(0), 0.5, 1, "COSINE")\` is called in the query expression.

Property-value-based functions can be called via the function of getScorableProperty(schemaType, propertyPath)

- In order to use this function, ScorablePropertyRanking feature must be enabled via `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setScorablePropertyRankingEnabled(boolean)`.
- Param 'schemaType' must be a valid AppSearch SchemaType otherwise an error is returned.
- Param 'propertyPath' must be valid and scorable otherwise an error is returned. It is considered scorable when:
  - It is to a property that is set to be enabled for scoring, or that
  - It points to a scorable property of nested schema types.
- This function returns a list double values for the matched documents.
  - If the matched document's schema is different from 'schemaType', or the property under the 'propertyPath' holds no element, an empty list is returned.
- Some examples below: Suppose that there are two schemas: 'Gmail' and 'Person'. 'Gmail' schema has a property 'recipient' with schema type 'Person'. In the advanced ranking expression, you can have:

  - "sum(getScorableProperty('Gmail', 'viewTimes'))"
  - "maxOrDefault(getScorableProperty('Person', 'income'), 0)"
  - "sum(getScorableProperty('Gmail', 'recipient.income'))"
  - "this.documentScore() + sum(getScorableProperty('Gmail', 'viewTimes'))"

The following functions are provided for enhanced list manipulation.

- minOrDefault(V, default_score) Returns the minimum value in the input list V or the default_score if the list is empty.

  Example: "minOrDefault(this.matchedSemanticScores(getEmbeddingParameter(0)), 10)" will return the minimum matched semantic scores or 10 if there is no matched score for the current document.

  This function requires the feature `https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features#SEARCH_SPEC_RANKING_FUNCTION_MAX_MIN_OR_DEFAULT()`.
- maxOrDefault(V, default_score) Returns the maximum value in the input list V or the default_score if the list is empty.

  Example: "maxOrDefault(this.matchedSemanticScores(getEmbeddingParameter(0)), -10)" will return the maximum matched semantic scores or -10 if there is no matched score for the current document.

  This function requires the feature `https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features#SEARCH_SPEC_RANKING_FUNCTION_MAX_MIN_OR_DEFAULT()`.
- filterByRange(V, low, high) Returns a sublist of V that only contains the elements that fall within the specified range \[low, high\].

  Example: "filterByRange(this.matchedSemanticScores(getEmbeddingParameter(0)), 0, 1)" will return a list of matched semantic scores that are between 0 and 1, inclusive.

  This function requires the feature `https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features#SEARCH_SPEC_RANKING_FUNCTION_FILTER_BY_RANGE()`.

Some errors may occur when using advanced ranking.

Syntax Error: the expression violates the syntax of the advanced ranking language. Below are some examples.

- "1 + " - missing operand
- "2 \* (1 + 2))" - unbalanced parenthesis
- "2 \^ 3" - unknown operator

Type Error: the expression fails a static type check. Below are some examples.

- "sin(2, 3)" - wrong number of arguments for the sin function
- "this.childrenRankingSignals() + 1" - cannot add a list with a number
- "this.propertyWeights()" - the final type of the overall expression cannot be a list, which can be fixed by "max(this.propertyWeights())"
- "abs(this.propertyWeights())" - the abs function does not support list type arguments
- "print(2)" - unknown function

Evaluation Error: an error occurred while evaluating the value of the expression. Below are some examples.

- "1 / 0", "log(0)", "1 + sqrt(-1)" - getting a non-finite value in the middle of evaluation
- "this.usageCount(1 + 0.5)" - expect the argument to be an integer. Note that this is not a type error and "this.usageCount(1.5 + 1/2)" can succeed without any issues
- "this.documentScore()" - in case of an IO error, this will be an evaluation error

Syntax errors and type errors will fail the entire search and will cause `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResults#getNextPageAsync()` to throw an `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` with the result code of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_INVALID_ARGUMENT()`.

Evaluation errors will result in the offending documents receiving the default score. For `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#ORDER_DESCENDING()`, the default score will be 0, for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#ORDER_ASCENDING()` the default score will be infinity.

| Parameters |
|---|---|
| `advancedRankingExpression: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | a non-empty string representing the ranking expression. |

### setRankingStrategy

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

```
fun setRankingStrategy(rankingStrategy: Int): SearchSpec.Builder
```

Sets ranking strategy for AppSearch results.

### setResultCountPerPage

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

```
fun setResultCountPerPage(
    resultCountPerPage: @IntRange(from = 0, to = 10000) Int
): SearchSpec.Builder
```

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

The default number of results per page is 10.

### setResultGrouping

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

```
fun setResultGrouping(groupingTypeFlags: Int, limit: Int): SearchSpec.Builder
```

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

Calling this method will override any previous calls. So calling `
setResultGrouping(GROUPING_TYPE_PER_PACKAGE, 7)` and then calling `
setResultGrouping(GROUPING_TYPE_PER_PACKAGE, 2)` will result in only the latter, a limit of two results per package, being applied. Or calling `setResultGrouping
(GROUPING_TYPE_PER_PACKAGE, 1)` and then calling `setResultGrouping
(GROUPING_TYPE_PER_PACKAGE | GROUPING_PER_NAMESPACE, 5)` will result in five results per package per namespace.

| Parameters |
|---|---|
| `groupingTypeFlags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | One or more combination of grouping types. |
| `limit: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Number of results to return per `groupingTypeFlags`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if groupingTypeFlags is zero. |

### setRetrieveEmbeddingMatchInfos

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_EMBEDDING_MATCH_INFO)
@ExperimentalAppSearchApi
fun setRetrieveEmbeddingMatchInfos(retrieveEmbeddingMatchInfos: Boolean): SearchSpec.Builder
```

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

Note that this does not modify the snippet count fields, and any retrieved embedding match infos also count toward the limit set in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getSnippetCount()` and `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#getSnippetCountPerProperty()`.

### setScorablePropertyRankingEnabled

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.SCHEMA_SCORABLE_PROPERTY_CONFIG)
@ExperimentalAppSearchApi
fun setScorablePropertyRankingEnabled(enabled: Boolean): SearchSpec.Builder
```

Sets the ScorablePropertyRanking feature as enabled or disabled.

If enabled, 'getScorableProperty' function can be used in the advanced ranking expression. For details, see `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(java.lang.String)`.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Enables the feature if true, otherwise disables it. |

### setSearchSourceLogTag

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_SET_SEARCH_SOURCE_LOG_TAG)
fun setSearchSourceLogTag(searchSourceLogTag: String): SearchSpec.Builder
```

Sets an optional log tag to indicate the source of this search.

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 this method 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.

| Parameters |
|---|---|
| `searchSourceLogTag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | A String to indicate the source caller of this search. It is used to label the search statsd for performance analysis. It is not the tag we are using in `https://developer.android.com/reference/android/util/Log.html`. The length of the teg should between 1 and 100. |

### setSnippetCount

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

```
fun setSnippetCount(snippetCount: @IntRange(from = 0, to = 10000) Int): SearchSpec.Builder
```

Sets the `snippetCount` such that the first `snippetCount` documents based on the ranking strategy will have snippet information provided.

The list returned from `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getMatchInfos()` will contain at most this many entries.

If set to 0 (default), snippeting is disabled and the list returned from `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getMatchInfos()` will be empty.

### setSnippetCountPerProperty

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

```
fun setSnippetCountPerProperty(
    snippetCountPerProperty: @IntRange(from = 0, to = 10000) Int
): SearchSpec.Builder
```

Sets `snippetCountPerProperty`. Only the first `snippetCountPerProperty` snippets for each property of each `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` will contain snippet information.

If set to 0, snippeting is disabled and the list returned from `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult#getMatchInfos()` will be empty.

The default behavior is to snippet all matches a property contains, up to the maximum value of 10,000.

### setTermMatch

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

```
fun setTermMatch(termMatchType: Int): SearchSpec.Builder
```

Sets how the query terms should match `TermMatchCode` in the index.

If this method is not called, the default term match type is `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec#TERM_MATCH_PREFIX()`.

### setVerbatimSearchEnabled

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.VERBATIM_SEARCH)
fun setVerbatimSearchEnabled(enabled: Boolean): SearchSpec.Builder
```

Sets the VERBATIM_SEARCH feature as enabled/disabled according to the enabled parameter.

| Parameters |
|---|---|
| `enabled: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Enables the feature if true, otherwise disables it If disabled, disallows use of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.StringPropertyConfig#TOKENIZER_TYPE_VERBATIM()` and all other verbatim search features within the query language that allows clients to search using the verbatim string operator. For example, The verbatim string operator '"foo/bar" OR baz' will ensure that 'foo/bar' is treated as a single 'verbatim' token. |