# AppSearchSchema

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

*** ** * ** ***


```
public final class AppSearchSchema
```

<br />

*** ** * ** ***

The AppSearch Schema for a particular type of document.

For example, an e-mail message or a music recording could be a schema type.

The schema consists of type information, properties, and config (like tokenization type).

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#setSchemaAsync(androidx.appsearch.app.SetSchemaRequest)` |   |

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.SCHEMA_BLOB_HANDLE) public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BlobHandlePropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property of type `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBlobHandle` in a Document. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BlobHandlePropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BlobHandlePropertyConfig`. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BooleanPropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property containing a boolean. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BooleanPropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BooleanPropertyConfig`. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema`. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BytesPropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property containing a byte array. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BytesPropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.BytesPropertyConfig`. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property containing another Document. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.DocumentPropertyConfig`. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.DoublePropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property containing a double-precision decimal number. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.DoublePropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.DoublePropertyConfig`. |
| `@https://developer.android.com/reference/androidx/annotation/RequiresFeature(enforcement = "androidx.appsearch.app.Features#isFeatureSupported", name = https://developer.android.com/reference/androidx/appsearch/app/Features.SCHEMA_EMBEDDING_PROPERTY_CONFIG) public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.EmbeddingPropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property of type `https://developer.android.com/reference/androidx/appsearch/app/EmbeddingVector` in a Document. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.EmbeddingPropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.EmbeddingPropertyConfig`. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.LongPropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property containing a 64-bit integer. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.LongPropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.LongPropertyConfig`. |
| `public abstract class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Common configuration for a single property (field) in a Document. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.StringPropertyConfig extends https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig` Configuration for a property of type String in a Document. |
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.StringPropertyConfig.Builder` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.StringPropertyConfig`. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema#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/AppSearchSchema` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema#fromDocumentClass(java.lang.Class<?>)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> documentClass)` Gets the generated `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema` for 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/java/lang/String.html` | `@https://developer.android.com/reference/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema#getDescription()()` Returns a natural language description of this schema type. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema#getParentTypes()()` Returns the list of parent types of this schema for polymorphism. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema#getProperties()()` Returns the list of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig`s that are part of this schema. |
| `@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/AppSearchSchema#getSchemaType()()` Returns the name of this schema type, such as Email. |
| `int` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema#hashCode()()` |
| `@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/AppSearchSchema#toString()()` |

## Public methods

### equals

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

### fromDocumentClass

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

```
@ExperimentalAppSearchApi
public static @NonNull AppSearchSchema fromDocumentClass(@NonNull Class<@NonNull ?> documentClass)
```

Gets the generated `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema` for a class annotated with \\@`https://developer.android.com/reference/androidx/appsearch/annotation/Document`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> documentClass` | 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/AppSearchSchema` | the generated `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema` for the given document class. |

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

### getDescription

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

```
@ExperimentalAppSearchApi
public @NonNull String getDescription()
```

Returns a natural language description of this schema type.

Ex. The description for an Email type could be "A type of electronic message".

This information is purely to help apps consuming this type to understand its semantic meaning. This field has no effect in AppSearch - it is just stored with the AppSearchSchema. If `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.Builder#setDescription(java.lang.String)` is uncalled, then this method will return an empty string.

### getParentTypes

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

```
public @NonNull List<String> getParentTypes()
```

Returns the list of parent types of this schema for polymorphism.

### getProperties

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

```
public @NonNull List<AppSearchSchema.PropertyConfig> getProperties()
```

Returns the list of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSchema.PropertyConfig`s that are part of this schema.

This method creates a new list when called.

### getSchemaType

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

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

Returns the name of this schema type, such as Email.

### hashCode

```
public int hashCode()
```

### toString

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