# AppSearchBatchResult

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

*** ** * ** ***

<br />

```
public final class AppSearchBatchResult<KeyType, ValueType>
```

<br />

*** ** * ** ***

Provides results for AppSearch batch operations which encompass multiple documents.

Individual results of a batch operation are separated into two maps: one for successes and one for failures. For successes, `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#getSuccesses()` will return a map of keys to instances of the value type. For failures, `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#getFailures()` will return a map of keys to `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` objects.

Alternatively, `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#getAll()` returns a map of keys to `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` objects for both successes and failures.

| Parameters |
|---|---|
| `<KeyType>` | The type of the keys for which the results will be reported. |
| `<ValueType>` | The type of the result objects for successful results. |

| 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#removeAsync(androidx.appsearch.app.RemoveByDocumentIdRequest)` |   |

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult.Builder<KeyType, ValueType>` Builder for `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult` objects. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<KeyType, https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult<ValueType>>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#getAll()()` Returns a `https://developer.android.com/reference/java/util/Map.html` of keys mapped to instances of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` for all individual results. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<KeyType, https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult<ValueType>>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#getFailures()()` Returns a `https://developer.android.com/reference/java/util/Map.html` of keys mapped to instances of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` for all failed individual results. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<KeyType, ValueType>` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#getSuccesses()()` Returns a `https://developer.android.com/reference/java/util/Map.html` of keys mapped to instances of the value type for all successful individual results. |
| `boolean` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#isSuccess()()` Returns `true` if this `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult` has no failures. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult#toString()()` |

## Public methods

### getAll

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

```
public @NonNull Map<KeyType, AppSearchResult<ValueType>> getAll()
```

Returns a `https://developer.android.com/reference/java/util/Map.html` of keys mapped to instances of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` for all individual results.

The values of the `https://developer.android.com/reference/java/util/Map.html` will not be `null`.

### getFailures

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

```
public @NonNull Map<KeyType, AppSearchResult<ValueType>> getFailures()
```

Returns a `https://developer.android.com/reference/java/util/Map.html` of keys mapped to instances of `https://developer.android.com/reference/androidx/appsearch/app/AppSearchResult` for all failed individual results.

The values of the `https://developer.android.com/reference/java/util/Map.html` will not be `null`.

### getSuccesses

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

```
public @NonNull Map<KeyType, ValueType> getSuccesses()
```

Returns a `https://developer.android.com/reference/java/util/Map.html` of keys mapped to instances of the value type for all successful individual results.

Example: `https://developer.android.com/reference/androidx/appsearch/app/AppSearchSession#getByDocumentIdAsync(androidx.appsearch.app.GetByDocumentIdRequest)` returns an `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult`. Each key (the document ID, of `String` type) will map to a `https://developer.android.com/reference/androidx/appsearch/app/GenericDocument` object.

The values of the `https://developer.android.com/reference/java/util/Map.html` will not be `null`.

### isSuccess

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

```
public boolean isSuccess()
```

Returns `true` if this `https://developer.android.com/reference/androidx/appsearch/app/AppSearchBatchResult` has no failures.

### toString

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