# 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 />

```
public class GenericDocument.Builder<BuilderType extends GenericDocument.Builder>
```

<br />

*** ** * ** ***

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

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#Builder(androidx.appsearch.app.GenericDocument)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/GenericDocument document)` Creates a new `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder` from the given GenericDocument. |
| `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#Builder(java.lang.String,java.lang.String,java.lang.String)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html namespace, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html id, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html schemaType )` Creates a new `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder`. |

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

```
public Builder(@NonNull GenericDocument document)
```

Creates a new `https://developer.android.com/reference/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)

```
public Builder(
    @NonNull String namespace,
    @NonNull String id,
    @NonNull String schemaType
)
```

Creates a new `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html namespace` | the namespace to set for the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html id` | the unique identifier for the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` in its namespace. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html schemaType` | the `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema` type of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`. The provided `schemaType` must be defined using `https://developer.android.com/reference/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/androidx/appsearch/app/AppSearchSession#putAsync(androidx.appsearch.app.PutDocumentsRequest)`. Otherwise, the document will be rejected by `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#putAsync(androidx.appsearch.app.PutDocumentsRequest)` with result code `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult#RESULT_NOT_FOUND()`. |

## Public methods

### build

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

```
public @NonNull GenericDocument build()
```

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

### clearProperty

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

```
public @NonNull BuilderType clearProperty(@NonNull String name)
```

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/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | The name of the property to clear. |

### setCreationTimestampMillis

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

```
public @NonNull BuilderType setCreationTimestampMillis(long creationTimestampMillis)
```

Sets the creation timestamp of the `https://developer.android.com/reference/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 |
|---|---|
| `long creationTimestampMillis` | a creation timestamp in milliseconds. |

### setId

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

```
public @NonNull BuilderType setId(@NonNull String id)
```

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)

```
public @NonNull BuilderType setNamespace(@NonNull String namespace)
```

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)
public @NonNull BuilderType setPropertyBlobHandle(
    @NonNull String name,
    @NonNull AppSearchBlobHandle[] values
)
```

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

`https://developer.android.com/reference/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/androidx/appsearch/app/AppSearchSession#openBlobForWriteAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)`. Once the blob data is committed via `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#commitBlobAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)`, the blob is retrievable via `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#openBlobForReadAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull AppSearchBlobHandle[] values` | the `https://developer.android.com/reference/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

```
public @NonNull BuilderType setPropertyBoolean(@NonNull String name, @NonNull boolean[] values)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull boolean[] values` | the `boolean` values of the property. |

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

### setPropertyBytes

```
public @NonNull BuilderType setPropertyBytes(@NonNull String name, @NonNull byte[][] values)
```

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/androidx/appsearch/app/GenericDocument.Builder#setPropertyBlobHandle(java.lang.String,androidx.appsearch.app.AppSearchBlobHandle...)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull byte[][] values` | 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

```
public @NonNull BuilderType setPropertyDocument(
    @NonNull String name,
    @NonNull GenericDocument[] values
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull GenericDocument[] values` | the `https://developer.android.com/reference/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/androidx/appsearch/app/GenericDocument` is `null`, or if name is empty. |

### setPropertyDouble

```
public @NonNull BuilderType setPropertyDouble(@NonNull String name, @NonNull double[] values)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull double[] values` | 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)
public @NonNull BuilderType setPropertyEmbedding(
    @NonNull String name,
    @NonNull EmbeddingVector[] values
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull EmbeddingVector[] values` | the `EmbeddingVector` values of the property. |

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

### setPropertyLong

```
public @NonNull BuilderType setPropertyLong(@NonNull String name, @NonNull long[] values)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull long[] values` | the `long` values of the property. |

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

### setPropertyString

```
public @NonNull BuilderType setPropertyString(@NonNull String name, @NonNull String[] values)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html name` | the name associated with the `values`. Must match the name for this property as given in `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getName()`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull String[] values` | 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)

```
public @NonNull BuilderType setSchemaType(@NonNull String schemaType)
```

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/androidx/appsearch/app/AppSearchSchema` object previously provided to `https://developer.android.com/reference/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)

```
public @NonNull BuilderType setScore(@IntRange(from = 0, to = Integer.MAX_VALUE) int score)
```

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

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

Results may be sorted by score using `https://developer.android.com/reference/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0, to = https://developer.android.com/reference/java/lang/Integer.html#MAX_VALUE) int score` | 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)

```
public @NonNull BuilderType setTtlMillis(long ttlMillis)
```

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

The TTL is measured against `https://developer.android.com/reference/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/androidx/appsearch/app/AppSearchSession#removeAsync(androidx.appsearch.app.RemoveByDocumentIdRequest)` is called.

| Parameters |
|---|---|
| `long ttlMillis` | a non-negative duration in milliseconds. |

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