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

*** ** * ** ***


```
class AppSearchSchema.DocumentPropertyConfig.Builder
```

<br />

*** ** * ** ***

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

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#Builder(java.lang.String,java.lang.String)(propertyName: 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/AppSearchSchema.DocumentPropertyConfig.Builder`. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedProperties(java.lang.String...)(indexableNestedProperties: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>)` Adds one or more properties for indexing from the nested document property. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedProperties(java.util.Collection<java.lang.String>)( indexableNestedProperties: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!> )` Adds one or more properties for indexing from the nested document. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedPropertyPaths(androidx.appsearch.app.PropertyPath...)( indexableNestedPropertyPaths: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!> )` Adds one or more property paths for indexing from the nested document property. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES) https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedPropertyPaths(java.util.Collection<androidx.appsearch.app.PropertyPath>)( indexableNestedPropertyPaths: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-collection/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath!> )` Adds one or more property paths for indexing from the nested document property. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#build()()` Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig` from the contents of this builder. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#setCardinality(int)(cardinality: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the cardinality of the property (whether it is optional, required or repeated). |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` | `@https://developer.android.com/reference/kotlin/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/kotlin/androidx/appsearch/app/Features.SCHEMA_SET_DESCRIPTION) @https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#setDescription(java.lang.String)(description: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Sets a natural language description of this property. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#setShouldIndexNestedProperties(boolean)(indexNestedProperties: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Configures whether properties in the nested document should be indexed according to that document's schema. |

## Public constructors

### Builder

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

```
Builder(propertyName: String, schemaType: String)
```

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

| Parameters |
|---|---|
| `propertyName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The logical name of the property in the schema, which will be used as the key for this property in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument.Builder#setPropertyDocument(java.lang.String,androidx.appsearch.app.GenericDocument...)`. |
| `schemaType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | The type of documents which will be stored in this property. Documents of different types cannot be mixed into a single property. |

## Public functions

### addIndexableNestedProperties

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES)
fun addIndexableNestedProperties(indexableNestedProperties: Array<String!>): AppSearchSchema.DocumentPropertyConfig.Builder
```

Adds one or more properties for indexing from the nested document property.

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

### addIndexableNestedProperties

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

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES)
fun addIndexableNestedProperties(
    indexableNestedProperties: (Mutable)Collection<String!>
): AppSearchSchema.DocumentPropertyConfig.Builder
```

Adds one or more properties for indexing from the nested document. The added property will be indexed according to that property's indexing configurations in the document's schema definition. All properties in this list will consume a sectionId regardless of its actual indexing config -- this includes properties added that do not actually exist, as well as properties that are not set as indexable in the nested schema type.

Input strings should follow the format of the property path for the nested property, with '.' as the path separator. This nested document's property name should not be included in the property path.

Ex. Consider an 'Organization' schema type which defines a nested document property 'address' (Address schema type), where Address has a nested document property 'country' (Country schema type with string 'name' property), and a string 'street' property. The 'street' and 'country's name' properties from the 'address' document property can be indexed for the 'Organization' schema type by calling:

```kotlin
OrganizationSchema.addProperty(
                new DocumentPropertyConfig.Builder("address", "Address")
                        .addIndexableNestedProperties("street", "country.name")
                        .build()).
```

`https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#setShouldIndexNestedProperties(boolean)` is required to be false if any indexable nested property is added this way for the document property. Attempting to build a DocumentPropertyConfig when this is not true throws `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`.

### addIndexableNestedPropertyPaths

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES)
fun addIndexableNestedPropertyPaths(
    indexableNestedPropertyPaths: Array<PropertyPath!>
): AppSearchSchema.DocumentPropertyConfig.Builder
```

Adds one or more property paths for indexing from the nested document property.

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

### addIndexableNestedPropertyPaths

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

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_ADD_INDEXABLE_NESTED_PROPERTIES)
fun addIndexableNestedPropertyPaths(
    indexableNestedPropertyPaths: (Mutable)Collection<PropertyPath!>
): AppSearchSchema.DocumentPropertyConfig.Builder
```

Adds one or more property paths for indexing from the nested document property.

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

### build

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

```
fun build(): AppSearchSchema.DocumentPropertyConfig
```

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

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the provided PropertyConfig sets `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig#shouldIndexNestedProperties()` to true and has one or more properties defined using `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedProperties(java.util.Collection<java.lang.String>)`. |

### setCardinality

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

```
fun setCardinality(cardinality: Int): AppSearchSchema.DocumentPropertyConfig.Builder
```

Sets the cardinality of the property (whether it is optional, required or repeated).

If this method is not called, the default cardinality is `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#CARDINALITY_OPTIONAL()`.

### setDescription

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

```
@RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = Features.SCHEMA_SET_DESCRIPTION)
@ExperimentalAppSearchApi
fun setDescription(description: String): AppSearchSchema.DocumentPropertyConfig.Builder
```

Sets a natural language description of this property.

For more details about the description field, see `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.PropertyConfig#getDescription()`.

### setShouldIndexNestedProperties

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

```
fun setShouldIndexNestedProperties(indexNestedProperties: Boolean): AppSearchSchema.DocumentPropertyConfig.Builder
```

Configures whether properties in the nested document should be indexed according to that document's schema.

If false, the nested document's properties are not indexed regardless of its own schema.

To index a subset of properties from the nested document, set this to false and use `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedProperties(java.util.Collection<java.lang.String>)`.