# GenericDocument

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

*** ** * ** ***

<br />

```
public class GenericDocument
```

<br />

*** ** * ** ***

Represents a document unit.

Documents contain structured data conforming to their `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema` type. Each document is uniquely identified by a namespace and a String ID within that namespace.

Documents are constructed either by using the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder` or providing an annotated `https://developer.android.com/reference/androidx/appsearch/annotation/Document` data class.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#putAsync(androidx.appsearch.app.PutDocumentsRequest)` |   |
| `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#getByDocumentIdAsync(androidx.appsearch.app.GetByDocumentIdRequest)` |   |
| `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)` |   |

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder<BuilderType extends https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder>` The builder class for `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`. |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#GenericDocument(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` from an existing instance. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#equals(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html other)` |
| `static @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#fromDocumentClass(java.lang.Object)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html document)` Converts an instance of a class annotated with \\@`https://developer.android.com/reference/androidx/appsearch/annotation/Document` into an instance of `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`. |
| `long` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getCreationTimestampMillis()()` Returns the creation timestamp of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`, in milliseconds. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getId()()` Returns the unique identifier of 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` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getNamespace()()` Returns the namespace of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves the property value with the given path as `https://developer.android.com/reference/java/lang/Object.html`. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyBlobHandle(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves an `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable AppSearchBlobHandle[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyBlobHandleArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a repeated `AppSearchBlobHandle[]` property by path. |
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyBoolean(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a `boolean` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable boolean[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyBooleanArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a repeated `boolean` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyBytes(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a `byte[]` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[][]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyBytesArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a `byte[][]` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyDocument(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable GenericDocument[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyDocumentArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a repeated `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` property by path. |
| `double` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyDouble(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a `double` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable double[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyDoubleArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a repeated `double` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyEmbedding(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves an `EmbeddingVector` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable EmbeddingVector[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyEmbeddingArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a repeated `EmbeddingVector[]` property by path. |
| `long` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyLong(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a `long` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable long[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyLongArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a repeated `long[]` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyNames()()` Returns the names of all properties defined in this document. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyString(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a `https://developer.android.com/reference/java/lang/String.html` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable String[]` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyStringArray(java.lang.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path)` Retrieves a repeated `String` property by path. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getSchemaType()()` Returns the `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema` type of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getScore()()` Returns the score of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`. |
| `long` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getTtlMillis()()` Returns the TTL (time-to-live) of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`, in milliseconds. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | `<T> https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#toDocumentClass(java.lang.Class<T>)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<T> documentClass)` Converts this GenericDocument into an instance of the provided document class. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi <T> https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#toDocumentClass(java.lang.Class<T>,androidx.appsearch.app.DocumentClassMappingContext)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<T> documentClass, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/DocumentClassMappingContext documentClassMappingContext )` Converts this GenericDocument into an instance of the provided document class. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#toString()()` |

## Protected constructors

### GenericDocument

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

```
protected GenericDocument(@NonNull GenericDocument document)
```

Creates a new `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` from an existing instance.

This method should be only used by constructor of a subclass.

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### fromDocumentClass

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

```
public static @NonNull GenericDocument fromDocumentClass(@NonNull Object document)
```

Converts an instance of a class annotated with \\@`https://developer.android.com/reference/androidx/appsearch/annotation/Document` into an instance of `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html document` | An instance of a class annotated with \\@`https://developer.android.com/reference/androidx/appsearch/annotation/Document`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` | an instance of `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` produced by converting `document`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException` | if no generated conversion class exists on the classpath for the given document class or an unexpected error occurs during conversion. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#toDocumentClass(java.lang.Class<T>)` |   |

### getCreationTimestampMillis

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

```
public long getCreationTimestampMillis()
```

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

The value is in the `https://developer.android.com/reference/java/lang/System.html#currentTimeMillis()` time base.

### getId

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

```
public @NonNull String getId()
```

Returns the unique identifier of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`.

### getNamespace

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

```
public @NonNull String getNamespace()
```

Returns the namespace of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`.

### getProperty

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

```
public @Nullable Object getProperty(@NonNull String path)
```

Retrieves the property value with the given path as `https://developer.android.com/reference/java/lang/Object.html`.

A path can be a simple property name, such as those returned by `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyNames()`. It may also be a dot-delimited path through the nested document hierarchy, with nested `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` properties accessed via `'.'` and repeated properties optionally indexed into via `[n]`.

For example, given the following `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`:

```
    (Message) {
        from: "sender@example.com"
        to: [{
            name: "Albert Einstein"
            email: "einstein@example.com"
          }, {
            name: "Marie Curie"
            email: "curie@example.com"
          }]
        tags: ["important", "inbox"]
        subject: "Hello"
    }
```

Here are some example paths and their results:

- `"from"` returns `"sender@example.com"` as a `https://developer.android.com/reference/java/lang/String.html` array with one element
- `"to"` returns the two nested documents containing contact information as a `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` array with two elements
- `"to[1]"` returns the second nested document containing Marie Curie's contact information as a `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` array with one element
- `"to[1].email"` returns `"curie@example.com"`
- `"to[100].email"` returns `null` as this particular document does not have that many elements in its `"to"` array.
- `"to.email"` aggregates emails across all nested documents that have them, returning `["einstein@example.com", "curie@example.com"]` as a `https://developer.android.com/reference/java/lang/String.html` array with two elements.

If you know the expected type of the property you are retrieving, it is recommended to use one of the typed versions of this method instead, such as `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyString(java.lang.String)` or `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getPropertyStringArray(java.lang.String)`.

If the property was assigned as an empty array using one of the `Builder#setProperty` functions, this method will return an empty array. If no such property exists at all, this method returns `null`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html` | The entry with the given path as an object or `null` if there is no such path. The returned object will be one of the following types: `String[]`, `long[]`, `double[]`, `boolean[]`, `byte[][]`, `GenericDocument[]`. |

### getPropertyBlobHandle

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

```
public @Nullable AppSearchBlobHandle getPropertyBlobHandle(@NonNull String path)
```

Retrieves an `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

See `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#openBlobForReadAsync(java.util.Set<androidx.appsearch.app.AppSearchBlobHandle>)` for how to use `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` to retrieve blob data.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` | The first `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` associated with the given path or `null` if there is no such value or the value is of a different type. |

### getPropertyBlobHandleArray

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

```
public @Nullable AppSearchBlobHandle[] getPropertyBlobHandleArray(@NonNull String path)
```

Retrieves a repeated `AppSearchBlobHandle[]` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyBlobHandle(java.lang.String,androidx.appsearch.app.AppSearchBlobHandle...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyBlobHandle(java.lang.String,androidx.appsearch.app.AppSearchBlobHandle...)` to an empty `AppSearchBlobHandle[]`, this method returns an empty `AppSearchBlobHandle[]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable AppSearchBlobHandle[]` | The `AppSearchBlobHandle[]` associated with the given path, or `null` if no value is set or the value is of a different type. |

### getPropertyBoolean

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

```
public boolean getPropertyBoolean(@NonNull String path)
```

Retrieves a `boolean` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `boolean` | The first `boolean` associated with the given path or default value `false` if there is no such value or the value is of a different type. |

### getPropertyBooleanArray

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

```
public @Nullable boolean[] getPropertyBooleanArray(@NonNull String path)
```

Retrieves a repeated `boolean` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyBoolean(java.lang.String,boolean...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyBoolean(java.lang.String,boolean...)` to an empty `boolean[]`, this method returns an empty `boolean[]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable boolean[]` | The `boolean[]` associated with the given path, or `null` if no value is set or the value is of a different type. |

### getPropertyBytes

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

```
public @Nullable byte[] getPropertyBytes(@NonNull String path)
```

Retrieves a `byte[]` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[]` | The first `byte[]` associated with the given path or `null` if there is no such value or the value is of a different type. |

### getPropertyBytesArray

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

```
public @Nullable byte[][] getPropertyBytesArray(@NonNull String path)
```

Retrieves a `byte[][]` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyBytes(java.lang.String,byte[]...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyBytes(java.lang.String,byte[]...)` to an empty `byte[][]`, this method returns an empty `byte[][]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable byte[][]` | The `byte[][]` associated with the given path, or `null` if no value is set or the value is of a different type. |

### getPropertyDocument

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

```
public @Nullable GenericDocument getPropertyDocument(@NonNull String path)
```

Retrieves a `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` | The first `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` associated with the given path or `null` if there is no such value or the value is of a different type. |

### getPropertyDocumentArray

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

```
public @Nullable GenericDocument[] getPropertyDocumentArray(@NonNull String path)
```

Retrieves a repeated `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyDocument(java.lang.String,androidx.appsearch.app.GenericDocument...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyDocument(java.lang.String,androidx.appsearch.app.GenericDocument...)` to an empty `GenericDocument[]`, this method returns an empty `GenericDocument[]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable GenericDocument[]` | The `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`\[\] associated with the given path, or `null` if no value is set or the value is of a different type. |

### getPropertyDouble

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

```
public double getPropertyDouble(@NonNull String path)
```

Retrieves a `double` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `double` | The first `double` associated with the given path or default value `0.0` if there is no such value or the value is of a different type. |

### getPropertyDoubleArray

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

```
public @Nullable double[] getPropertyDoubleArray(@NonNull String path)
```

Retrieves a repeated `double` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyDouble(java.lang.String,double...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyDouble(java.lang.String,double...)` to an empty `double[]`, this method returns an empty `double[]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable double[]` | The `double[]` associated with the given path, or `null` if no value is set or the value is of a different type. |

### getPropertyEmbedding

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

```
public @Nullable EmbeddingVector getPropertyEmbedding(@NonNull String path)
```

Retrieves an `EmbeddingVector` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector` | The first `EmbeddingVector[]` associated with the given path or `null` if there is no such value or the value is of a different type. |

### getPropertyEmbeddingArray

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

```
public @Nullable EmbeddingVector[] getPropertyEmbeddingArray(@NonNull String path)
```

Retrieves a repeated `EmbeddingVector[]` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyEmbedding(java.lang.String,androidx.appsearch.app.EmbeddingVector...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyEmbedding(java.lang.String,androidx.appsearch.app.EmbeddingVector...)` to an empty `EmbeddingVector[]`, this method returns an empty `EmbeddingVector[]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable EmbeddingVector[]` | The `EmbeddingVector[]` associated with the given path, or `null` if no value is set or the value is of a different type. |

### getPropertyLong

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

```
public long getPropertyLong(@NonNull String path)
```

Retrieves a `long` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `long` | The first `long` associated with the given path or default value `0` if there is no such value or the value is of a different type. |

### getPropertyLongArray

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

```
public @Nullable long[] getPropertyLongArray(@NonNull String path)
```

Retrieves a repeated `long[]` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyLong(java.lang.String,long...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyLong(java.lang.String,long...)` to an empty `long[]`, this method returns an empty `long[]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable long[]` | The `long[]` associated with the given path, or `null` if no value is set or the value is of a different type. |

### getPropertyNames

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

```
public @NonNull Set<String> getPropertyNames()
```

Returns the names of all properties defined in this document.

### getPropertyString

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

```
public @Nullable String getPropertyString(@NonNull String path)
```

Retrieves a `https://developer.android.com/reference/java/lang/String.html` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/String.html` | The first `https://developer.android.com/reference/java/lang/String.html` associated with the given path or `null` if there is no such value or the value is of a different type. |

### getPropertyStringArray

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

```
public @Nullable String[] getPropertyStringArray(@NonNull String path)
```

Retrieves a repeated `String` property by path.

See `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getProperty(java.lang.String)` for a detailed description of the path syntax.

If the property has not been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyString(java.lang.String,java.lang.String...)`, this method returns `null`.

If it has been set via `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument.Builder#setPropertyString(java.lang.String,java.lang.String...)` to an empty `String[]`, this method returns an empty `String[]`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html path` | The path to look for. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable String[]` | The `String[]` associated with the given path, or `null` if no value is set or the value is of a different type. |

### getSchemaType

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

```
public @NonNull String getSchemaType()
```

Returns the `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema` type of the `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument`.

### getScore

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

```
public int getScore()
```

Returns 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.

### getTtlMillis

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

```
public long getTtlMillis()
```

Returns 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.

### hashCode

```
public int hashCode()
```

### toDocumentClass

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

```
public @NonNull T <T> toDocumentClass(@NonNull Class<T> documentClass)
```

Converts this GenericDocument into an instance of the provided document class.

It is the developer's responsibility to ensure the right kind of document class is being supplied here, either by structuring the application code to ensure the document type is known, or by checking the return value of `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getSchemaType()`.

Document properties are identified by `String` names. Any that are found are assigned into fields of the given document class. As such, the most likely outcome of supplying the wrong document class would be an empty or partially populated result.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<T> documentClass` | a class annotated with `https://developer.android.com/reference/androidx/appsearch/annotation/Document` |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | an instance of the document class after being converted from a `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException` | if no factory for this document class could be found on the classpath. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#fromDocumentClass(java.lang.Object)` |   |

### toDocumentClass

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

```
@ExperimentalAppSearchApi
public @NonNull T <T> toDocumentClass(
    @NonNull Class<T> documentClass,
    @NonNull DocumentClassMappingContext documentClassMappingContext
)
```

Converts this GenericDocument into an instance of the provided document class.

It is the developer's responsibility to ensure the right kind of document class is being supplied here, either by structuring the application code to ensure the document type is known, or by checking the return value of `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#getSchemaType()`.

Document properties are identified by `String` names. Any that are found are assigned into fields of the given document class. As such, the most likely outcome of supplying the wrong document class would be an empty or partially populated result.

If this GenericDocument's type is recorded as a subtype of the provided `documentClass`, the method will find an AppSearch document class, using the provided `documentClassMappingContext`, that is the most concrete and assignable to `documentClass`, and then deserialize to that class instead. This allows for more specific and accurate deserialization of GenericDocuments. If `documentClassMappingContext` has information missing or we are not able to find a candidate assignable to `documentClass`, the method will deserialize to `documentClass` directly.

Assignability is determined by the programing language's type system, and which type is more concrete is determined by AppSearch's type system specified via `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.Builder#addParentType(java.lang.String)` or the annotation parameter `https://developer.android.com/reference/androidx/appsearch/annotation/Document#parent()`.

For nested document properties, this method will be called recursively, and `documentClassMappingContext` will be passed down to the recursive calls of this method.

For most use cases, it is recommended to utilize `https://developer.android.com/reference/androidx/appsearch/app/SearchResult#getDocument(java.lang.Class<T>,java.util.Map<java.lang.String,java.util.List<java.lang.String>>)` instead of calling this method directly. This avoids the need to manually create a `https://developer.android.com/reference/androidx/appsearch/app/DocumentClassMappingContext`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<T> documentClass` | a class annotated with `https://developer.android.com/reference/androidx/appsearch/annotation/Document` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appsearch/app/DocumentClassMappingContext documentClassMappingContext` | a `https://developer.android.com/reference/androidx/appsearch/app/DocumentClassMappingContext` instance |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T` | an instance of the document class after being converted from a `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/exceptions/AppSearchException` | if no factory for this document class could be found on the classpath. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument#fromDocumentClass(java.lang.Object)` |   |

### toString

```
public @NonNull String toString()
```