# GenericDocument.Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/appsearch/GenericDocument.Builder "View this page in Java")  

```
open class Builder<BuilderType : GenericDocument.Builder<GenericDocument.Builder<*>>!>
```

|---|------------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                                 ||
| ↳ | [android.app.appsearch.GenericDocument.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#) |

The builder class for[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument).

## Summary

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

|                                                                                                                                                                                                                                                                                                                                                                   Public methods                                                                                                                                                                                                                                                                                                                                                                   ||
|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument) | [build](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#build())`()` Builds the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)object.                                                                                                                                                                                                                                                                                                                                                                                            |
| openBuilderType                                                                                             | [clearProperty](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#clearProperty(kotlin.String))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Clears the value for the property with the given name.                                                                                                                                                                                                                                                                                                                                       |
| openBuilderType                                                                                             | [setCreationTimestampMillis](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setCreationTimestampMillis(kotlin.Long))`(`creationTimestampMillis:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Sets the creation timestamp of the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument), in milliseconds.                                                                                                                                                                                           |
| openBuilderType                                                                                             | [setId](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setId(kotlin.String))`(`id:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the ID of this document, changing the value provided in the constructor.                                                                                                                                                                                                                                                                                                                                  |
| openBuilderType                                                                                             | [setNamespace](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setNamespace(kotlin.String))`(`namespace:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the app-defined namespace this document resides in, changing the value provided in the constructor.                                                                                                                                                                                                                                                                                  |
| openBuilderType                                                                                             | [setPropertyBlobHandle](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyBlobHandle(kotlin.String,%20android.app.appsearch.AppSearchBlobHandle))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[AppSearchBlobHandle](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBlobHandle)!`)` Sets one or multiple[AppSearchBlobHandle](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBlobHandle)values for a property, replacing its previous values. |
| openBuilderType                                                                                             | [setPropertyBoolean](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyBoolean(kotlin.String,%20kotlin.Boolean))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html)`)` Sets one or multiple`boolean`values for a property, replacing its previous values.                                                                                                                                                                      |
| openBuilderType                                                                                             | [setPropertyBytes](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyBytes(kotlin.String,%20kotlin.ByteArray))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`)` Sets one or multiple`byte[]`for a property, replacing its previous values.                                                                                                                                                                          |
| openBuilderType                                                                                             | [setPropertyDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyDocument(kotlin.String,%20android.app.appsearch.GenericDocument))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)!`)` Sets one or multiple[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)values for a property, replacing its previous values.                         |
| openBuilderType                                                                                             | [setPropertyDouble](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyDouble(kotlin.String,%20kotlin.Double))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)`)` Sets one or multiple`double`values for a property, replacing its previous values.                                                                                                                                                                            |
| openBuilderType                                                                                             | [setPropertyEmbedding](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyEmbedding(kotlin.String,%20android.app.appsearch.EmbeddingVector))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[EmbeddingVector](https://developer.android.com/reference/kotlin/android/app/appsearch/EmbeddingVector)!`)` Sets one or multiple`EmbeddingVector`values for a property, replacing its previous values.                                                                                                             |
| openBuilderType                                                                                             | [setPropertyLong](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyLong(kotlin.String,%20kotlin.Long))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Sets one or multiple`long`values for a property, replacing its previous values.                                                                                                                                                                                        |
| openBuilderType                                                                                             | [setPropertyString](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyString(kotlin.String,%20kotlin.String))`(`name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `vararg` `values:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Sets one or multiple`String`values for a property, replacing its previous values.                                                                                                                                                                           |
| openBuilderType                                                                                             | [setSchemaType](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setSchemaType(kotlin.String))`(`schemaType:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Sets the schema type of this document, changing the value provided in the constructor.                                                                                                                                                                                                                                                                                                 |
| openBuilderType                                                                                             | [setScore](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setScore(kotlin.Int))`(`score:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Sets the score of the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument).                                                                                                                                                                                                                                                                                  |
| openBuilderType                                                                                             | [setTtlMillis](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setTtlMillis(kotlin.Long))`(`ttlMillis:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`)` Sets the TTL (time-to-live) of the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument), in milliseconds.                                                                                                                                                                                                                                     |

## Public constructors

### Builder

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

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

Creates a new[GenericDocument.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/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.

|                                                                   Parameters                                                                    ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `document` | [GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument):This value cannot be`null`. |

### Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

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

Creates a new[GenericDocument.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#).

Document IDs are unique within a namespace.

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

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `namespace`  | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the namespace to set for the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument). This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `id`         | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the unique identifier for the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)in its namespace. This value cannot be`null`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the[AppSearchSchema](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema)type of the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument). The provided`schemaType`must be defined using[AppSearchSession.setSchema](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#setSchema(android.app.appsearch.SetSchemaRequest,%20java.util.concurrent.Executor,%20java.util.concurrent.Executor,%20java.util.function.Consumer))prior to inserting a document of this`schemaType`into the AppSearch index using[AppSearchSession.put](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#put(android.app.appsearch.PutDocumentsRequest,%20java.util.concurrent.Executor,%20android.app.appsearch.BatchResultCallback)). Otherwise, the document will be rejected by[AppSearchSession.put](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#put(android.app.appsearch.PutDocumentsRequest,%20java.util.concurrent.Executor,%20android.app.appsearch.BatchResultCallback))with result code[android.app.appsearch.AppSearchResult#RESULT_NOT_FOUND](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchResult#RESULT_NOT_FOUND:kotlin.Int). This value cannot be`null`. |

## Public methods

### build

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

Builds the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)object.

|                                                                Return                                                                ||
|---------------------------------------------------------------------------------------------------------|-----------------------------|
| [GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument) | This value cannot be`null`. |

### clearProperty

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
open 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[getPropertyNames](https://developer.android.com/reference/kotlin/android/app/appsearch/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` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):The name of the property to clear. This value cannot be`null`. |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

### setCreationTimestampMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

Sets the creation timestamp of the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument), in milliseconds.

This should be set using a value obtained from the[System.currentTimeMillis](https://developer.android.com/reference/kotlin/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` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):a creation timestamp in milliseconds. Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

### setId

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
open 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.

|                                                     Parameters                                                     ||
|------|--------------------------------------------------------------------------------------------------------------|
| `id` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

### setNamespace

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
open 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.

|                                                        Parameters                                                         ||
|-------------|--------------------------------------------------------------------------------------------------------------|
| `namespace` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

### setPropertyBlobHandle

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 17](https://developer.android.com/sdkExtensions)  

```
open fun setPropertyBlobHandle(
    name: String, 
    vararg values: AppSearchBlobHandle!
): BuilderType
```

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

[AppSearchBlobHandle](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBlobHandle)is a pointer to a blob of data.

Store large byte via the[android.os.ParcelFileDescriptor](https://developer.android.com/reference/kotlin/android/os/ParcelFileDescriptor.html#)returned from[android.app.appsearch.AppSearchSession#openBlobForWrite](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#openBlobForWrite(kotlin.collections.MutableSet,%20java.util.concurrent.Executor,%20java.util.function.Consumer)). Once the blob data is committed via[android.app.appsearch.AppSearchSession#commitBlob](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#commitBlob(kotlin.collections.MutableSet,%20java.util.concurrent.Executor,%20java.util.function.Consumer)), the blob is retrievable via[android.app.appsearch.AppSearchSession#openBlobForRead](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#openBlobForRead(kotlin.collections.MutableSet,%20java.util.concurrent.Executor,%20java.util.function.Consumer)).

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [AppSearchBlobHandle](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBlobHandle)!:the[AppSearchBlobHandle](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchBlobHandle)values of the property. This value cannot be`null`.                                                                       |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                              Exceptions                              ||
|--------------------------------------|--------------------------------|
| `java.lang.IllegalArgumentException` | if the name is empty or`null`. |

### setPropertyBoolean

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setPropertyBoolean(
    name: String, 
    vararg values: Boolean
): BuilderType
```

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

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html):the`boolean`values of the property. This value cannot be`null`.                                                                                                                                                                                                           |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                              Exceptions                              ||
|--------------------------------------|--------------------------------|
| `java.lang.IllegalArgumentException` | if the name is empty or`null`. |

### setPropertyBytes

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setPropertyBytes(
    name: String, 
    vararg values: ByteArray!
): BuilderType
```

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

For large byte data and lazy retrieval, see[setPropertyBlobHandle](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument.Builder#setPropertyBlobHandle(kotlin.String,%20android.app.appsearch.AppSearchBlobHandle)).

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!:the`byte[]`of the property. This value cannot be`null`.                                                                                                                                                                                                             |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                                                        Exceptions                                                        ||
|--------------------------------------|------------------------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if no values are provided, or if a passed in`byte[]`is`null`, or if name is empty. |

### setPropertyDocument

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setPropertyDocument(
    name: String, 
    vararg values: GenericDocument!
): BuilderType
```

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

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)!:the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)values of the property. This value cannot be`null`.                                                                                       |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

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

### setPropertyDouble

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setPropertyDouble(
    name: String, 
    vararg values: Double
): BuilderType
```

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

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html):the`double`values of the property. This value cannot be`null`.                                                                                                                                                                                                              |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                              Exceptions                              ||
|--------------------------------------|--------------------------------|
| `java.lang.IllegalArgumentException` | if the name is empty or`null`. |

### setPropertyEmbedding

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 16](https://developer.android.com/sdkExtensions)  

```
open fun setPropertyEmbedding(
    name: String, 
    vararg values: EmbeddingVector!
): BuilderType
```

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

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [EmbeddingVector](https://developer.android.com/reference/kotlin/android/app/appsearch/EmbeddingVector)!:the`EmbeddingVector`values of the property. This value cannot be`null`.                                                                                                                                                                             |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                              Exceptions                              ||
|--------------------------------------|--------------------------------|
| `java.lang.IllegalArgumentException` | if the name is empty or`null`. |

### setPropertyLong

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setPropertyLong(
    name: String, 
    vararg values: Long
): BuilderType
```

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

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):the`long`values of the property. This value cannot be`null`.                                                                                                                                                                                                                    |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                              Exceptions                              ||
|--------------------------------------|--------------------------------|
| `java.lang.IllegalArgumentException` | if the name is empty or`null`. |

### setPropertyString

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setPropertyString(
    name: String, 
    vararg values: String!
): BuilderType
```

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

|                                                                                                                                                                               Parameters                                                                                                                                                                               ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `name`   | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the name associated with the`values`. Must match the name for this property as given in[AppSearchSchema.PropertyConfig.getName](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema.PropertyConfig#getName()). This value cannot be`null`. |
| `values` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!:the`String`values of the property. This value cannot be`null`.                                                                                                                                                                                                             |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                                                Exceptions                                                ||
|--------------------------------------|--------------------------------------------------------------------|
| `java.lang.IllegalArgumentException` | if no values are provided, or if a passed in`String`is`null`or "". |

### setSchemaType

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 13](https://developer.android.com/sdkExtensions)  

```
open 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[AppSearchSchema](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSchema)object previously provided to[AppSearchSession.setSchema](https://developer.android.com/reference/kotlin/android/app/appsearch/AppSearchSession#setSchema(android.app.appsearch.SetSchemaRequest,%20java.util.concurrent.Executor,%20java.util.concurrent.Executor,%20java.util.function.Consumer)).

|                                                         Parameters                                                         ||
|--------------|--------------------------------------------------------------------------------------------------------------|
| `schemaType` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):This value cannot be`null`. |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

### setScore

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setScore(score: Int): BuilderType
```

Sets the score of the[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument).

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

Results may be sorted by score using android.app.appsearch.SearchSpec.Builder#setRankingStrategy. 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` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):any non-negative`int`representing the document's score. Value is between 0 and[java.lang.Integer#MAX_VALUE](https://developer.android.com/reference/kotlin/java/lang/Integer.html#MAX_VALUE:kotlin.Int)inclusive |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                           Exceptions                            ||
|--------------------------------------|---------------------------|
| `java.lang.IllegalArgumentException` | if the score is negative. |

### setTtlMillis

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

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

The TTL is measured against[getCreationTimestampMillis](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument#getCreationTimestampMillis()). At the timestamp of`creationTimestampMillis + ttlMillis`, measured in the[java.lang.System#currentTimeMillis](https://developer.android.com/reference/kotlin/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 android.app.appsearch.AppSearchSession#remove is called.

|                                                             Parameters                                                             ||
|-------------|-----------------------------------------------------------------------------------------------------------------------|
| `ttlMillis` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):a non-negative duration in milliseconds. |

|                  Return                  ||
|-------------|-----------------------------|
| BuilderType | This value cannot be`null`. |

|                           Exceptions                            ||
|--------------------------------------|---------------------------|
| `java.lang.IllegalArgumentException` | if ttlMillis is negative. |