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

*** ** * ** ***

<br />

```
class GenericDocument.Builder<BuilderType : GenericDocument.Builder?>
```

<br />

*** ** * ** ***

The builder class for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`.

| Parameters |
|---|---|
| `<BuilderType : https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder?>` | Type of subclass who extends this. |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#Builder(androidx.appsearch.app.GenericDocument)(document: https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument)` Creates a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder` from the given GenericDocument. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#Builder(java.lang.String,java.lang.String,java.lang.String)(namespace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Creates a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#build()()` Builds the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` object. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#clearProperty(java.lang.String)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Clears the value for the property with the given name. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setCreationTimestampMillis(long)(creationTimestampMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the creation timestamp of the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`, in milliseconds. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setId(java.lang.String)(id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the ID of this document, changing the value provided in the constructor. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setNamespace(java.lang.String)(namespace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the app-defined namespace this document resides in, changing the value provided in the constructor. |
| `BuilderType` | `@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_BLOB_HANDLE) https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyBlobHandle(java.lang.String,androidx.appsearch.app.AppSearchBlobHandle...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBlobHandle!>)` Sets one or multiple `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBlobHandle` values for a property, replacing its previous values. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyBoolean(java.lang.String,boolean...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>)` Sets one or multiple `boolean` values for a property, replacing its previous values. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyBytes(java.lang.String,byte[]...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>)` Sets one or multiple `byte[]` for a property, replacing its previous values. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyDocument(java.lang.String,androidx.appsearch.app.GenericDocument...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument!>)` Sets one or multiple `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` values for a property, replacing its previous values. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyDouble(java.lang.String,double...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html>)` Sets one or multiple `double` values for a property, replacing its previous values. |
| `BuilderType` | `@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/GenericDocument.Builder#setPropertyEmbedding(java.lang.String,androidx.appsearch.app.EmbeddingVector...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector!>)` Sets one or multiple `EmbeddingVector` values for a property, replacing its previous values. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyLong(java.lang.String,long...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>)` Sets one or multiple `long` values for a property, replacing its previous values. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyString(java.lang.String,java.lang.String...)(name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Sets one or multiple `String` values for a property, replacing its previous values. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setSchemaType(java.lang.String)(schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets the schema type of this document, changing the value provided in the constructor. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setScore(int)(score: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the score of the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`. |
| `BuilderType` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setTtlMillis(long)(ttlMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Sets the TTL (time-to-live) of the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`, in milliseconds. |

## Public constructors

### Builder

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

```
Builder(document: GenericDocument)
```

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

The GenericDocument is deep copied, that is, it changes to a new GenericDocument returned by this function and will NOT affect the original GenericDocument.

### Builder

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

```
Builder(namespace: String, id: String, schemaType: String)
```

Creates a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder`.

Document IDs are unique within a namespace.

The number of namespaces per app should be kept small for efficiency reasons.

| Parameters |
|---|---|
| `namespace: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the namespace to set for the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`. |
| `id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the unique identifier for the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` in its namespace. |
| `schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` type of the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`. The provided `schemaType` must be defined using `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#setSchemaAsync(androidx.appsearch.app.SetSchemaRequest)` prior to inserting a document of this `schemaType` into the AppSearch index using `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#putAsync(androidx.appsearch.app.PutDocumentsRequest)`. Otherwise, the document will be rejected by `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#putAsync(androidx.appsearch.app.PutDocumentsRequest)` with result code `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_NOT_FOUND()`. |

## Public functions

### build

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

```
fun build(): GenericDocument
```

Builds the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` object.

### clearProperty

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

```
fun clearProperty(name: String): BuilderType
```

Clears the value for the property with the given name.

Note that this method does not support property paths.

You should check for the existence of the property in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument#getPropertyNames()` if you need to make sure the property being cleared actually exists.

If the string passed is an invalid or nonexistent property, no error message or behavior will be observed.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The name of the property to clear. |

### setCreationTimestampMillis

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

```
fun setCreationTimestampMillis(creationTimestampMillis: Long): BuilderType
```

Sets the creation timestamp of the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`, in milliseconds.

This should be set using a value obtained from the `https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()` time base.

If this method is not called, this will be set to the time the object is built.

| Parameters |
|---|---|
| `creationTimestampMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | a creation timestamp in milliseconds. |

### setId

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

```
fun setId(id: String): BuilderType
```

Sets the ID of this document, changing the value provided in the constructor. No special values are reserved or understood by the infrastructure.

Document IDs are unique within the combination of package, database, and namespace.

Setting a document with a duplicate id will overwrite the original document with the new document, enforcing uniqueness within the above constraint.

### setNamespace

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

```
fun setNamespace(namespace: String): BuilderType
```

Sets the app-defined namespace this document resides in, changing the value provided in the constructor. No special values are reserved or understood by the infrastructure.

Document IDs are unique within a namespace.

The number of namespaces per app should be kept small for efficiency reasons.

### setPropertyBlobHandle

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_BLOB_HANDLE)
fun setPropertyBlobHandle(name: String, values: Array<AppSearchBlobHandle!>): BuilderType
```

Sets one or multiple `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBlobHandle` values for a property, replacing its previous values.

`https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBlobHandle` is a pointer to a blob of data.

Store large byte via the `https://developer.android.com/reference/android/os/ParcelFileDescriptor.html` returned from `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#openBlobForWriteAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)`. Once the blob data is committed via `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#commitBlobAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)`, the blob is retrievable via `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#openBlobForReadAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)`.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBlobHandle!>` | the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchBlobHandle` values of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the name is empty or `null`. |

### setPropertyBoolean

```
fun setPropertyBoolean(name: String, values: BooleanArray<Boolean>): BuilderType
```

Sets one or multiple `boolean` values for a property, replacing its previous values.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html>` | the `boolean` values of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the name is empty or `null`. |

### setPropertyBytes

```
fun setPropertyBytes(name: String, values: Array<ByteArray<Byte>!>): BuilderType
```

Sets one or multiple `byte[]` for a property, replacing its previous values.

For large byte data and lazy retrieval, see `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyBlobHandle(java.lang.String,androidx.appsearch.app.AppSearchBlobHandle...)`.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>!>` | the `byte[]` of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if no values are provided, or if a passed in `byte[]` is `null`, or if name is empty. |

### setPropertyDocument

```
fun setPropertyDocument(name: String, values: Array<GenericDocument!>): BuilderType
```

Sets one or multiple `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` values for a property, replacing its previous values.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument!>` | the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` values of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if no values are provided, or if a passed in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` is `null`, or if name is empty. |

### setPropertyDouble

```
fun setPropertyDouble(name: String, values: DoubleArray<Double>): BuilderType
```

Sets one or multiple `double` values for a property, replacing its previous values.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html>` | the `double` values of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the name is empty or `null`. |

### setPropertyEmbedding

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_EMBEDDING_PROPERTY_CONFIG)
fun setPropertyEmbedding(name: String, values: Array<EmbeddingVector!>): BuilderType
```

Sets one or multiple `EmbeddingVector` values for a property, replacing its previous values.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/EmbeddingVector!>` | the `EmbeddingVector` values of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the name is empty or `null`. |

### setPropertyLong

```
fun setPropertyLong(name: String, values: LongArray<Long>): BuilderType
```

Sets one or multiple `long` values for a property, replacing its previous values.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>` | the `long` values of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the name is empty or `null`. |

### setPropertyString

```
fun setPropertyString(name: String, values: Array<String!>): BuilderType
```

Sets one or multiple `String` values for a property, replacing its previous values.

| Parameters |
|---|---|
| `name: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `values: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>` | the `String` values of the property. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if no values are provided, or if a passed in `String` is `null` or "". |

### setSchemaType

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

```
fun setSchemaType(schemaType: String): BuilderType
```

Sets the schema type of this document, changing the value provided in the constructor.

To successfully index a document, the schema type must match the name of an `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` object previously provided to `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#setSchemaAsync(androidx.appsearch.app.SetSchemaRequest)`.

### setScore

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

```
fun setScore(score: @IntRange(from = 0, to = Integer.MAX_VALUE) Int): BuilderType
```

Sets the score of the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`.

The score is a query-independent measure of the document's quality, relative to other `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument` objects of the same `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema` type.

Results may be sorted by score using `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchSpec.Builder#setRankingStrategy(int)`. Documents with higher scores are considered better than documents with lower scores.

Any non-negative integer can be used a score. By default, scores are set to 0.

| Parameters |
|---|---|
| `score: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0, to = https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | any non-negative `int` representing the document's score. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the score is negative. |

### setTtlMillis

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

```
fun setTtlMillis(ttlMillis: Long): BuilderType
```

Sets the TTL (time-to-live) of the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`, in milliseconds.

The TTL is measured against `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument#getCreationTimestampMillis()`. At the timestamp of `creationTimestampMillis + ttlMillis`, measured in the `https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()` time base, the document will be auto-deleted.

The default value is 0, which means the document is permanent and won't be auto-deleted until the app is uninstalled or `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#removeAsync(androidx.appsearch.app.RemoveByDocumentIdRequest)` is called.

| Parameters |
|---|---|
| `ttlMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | a non-negative duration in milliseconds. |

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