# Document.DocumentProperty

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/annotation/Document.java+class:androidx.appsearch.annotation.Document.DocumentProperty) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
@Documented
@Retention(value = RetentionPolicy.CLASS)
@Target(value = [ElementType.FIELD, ElementType.METHOD])
annotation Document.DocumentProperty
```

<br />

*** ** * ** ***

Configures a member field of a class as a property known to AppSearch.

Field's data class is required to be annotated with `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document`.

## Summary

| ### Public functions |
|---|---|
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#indexNestedProperties()()` Configures whether all fields in the nested document should be indexed. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!` | `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#indexableNestedPropertiesList()()` The list of properties in the nested document to index. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#inheritIndexableNestedPropertiesFromSuperclass()()` Configures whether to inherit the indexable nested properties list from the Document's superclass type definition. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#name()()` The name of this property. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#required()()` Configures whether this property must be specified for the document to be valid. |

## Public functions

### indexNestedProperties

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

```
abstract fun indexNestedProperties(): Boolean
```

Configures whether all fields in the nested document should be indexed.

If false, the nested document's properties are not indexed regardless of its own schema, unless `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#indexableNestedPropertiesList()` is used to index a subset of properties from the nested document.

`https://developer.android.com/reference/java/lang/IllegalArgumentException.html` will be thrown during setSchema if set to true and defining a non-empty list for `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#indexableNestedPropertiesList()`

### indexableNestedPropertiesList

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

```
abstract fun indexableNestedPropertiesList(): Array<String!>!
```

The list of properties in the nested document to index. The property will be indexed according to its indexing configurations in the document's schema definition.

`https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#indexNestedProperties()` is required to be false if this list is non-empty. `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` will be thrown during setSchema if this condition is not met.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedProperties(Collection)` | AppSearchSchema.DocumentPropertyConfig.Builder#addIndexableNestedProperties(Collection) |

### inheritIndexableNestedPropertiesFromSuperclass

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

```
abstract fun inheritIndexableNestedPropertiesFromSuperclass(): Boolean
```

Configures whether to inherit the indexable nested properties list from the Document's superclass type definition. When set to true, the indexable property paths will be a union of the paths specified in `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document.DocumentProperty#indexableNestedPropertiesList()` and any path specified in the document class's superclass or inherited interfaces. Effectively, this is a no-op if none of the document superclasses specify a path for this document property.

Ex. Consider the following Document classes:

```kotlin
class Person {
  = {"streetName", "zipcode"})
  Address livesAt;
}

class Artist extends Person {
  
    indexableNestedPropertiesList = {"country"},
    inheritIndexableNestedPropertiesFromSuperclass = true
  )
  Address livesAt;
}
```

By setting 'inheritIndexableNestedPropertiesFromSuperclass = true', Artist.livesAt inherits the indexable nested properties defined by its parent class's livesAt field (Person.livesAt) and indexes all three fields: {streetName, zipCode, country}

### name

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

```
abstract fun name(): String!
```

The name of this property. This string is used to query against this property.

If not specified, the name of the field in the code will be used instead.

### required

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

```
abstract fun required(): Boolean
```

Configures whether this property must be specified for the document to be valid.

This attribute does not apply to properties of a repeated type (e.g. a list).

Please make sure you understand the consequences of required fields on `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#setSchemaAsync(androidx.appsearch.app.SetSchemaRequest)` before setting this attribute to `true`.