# AppSearchResult

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

*** ** * ** ***


```
class AppSearchResult<ValueType>
```

<br />

*** ** * ** ***

Information about the success or failure of an AppSearch call.

| Parameters |
|---|---|
| `<ValueType>` | The type of result object for successful calls. |

## Summary

| ### Constants |
|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_ABORTED() = 13` The operation is aborted because an internal state change invalidated the results of the request. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_ALREADY_EXISTS() = 12` The operation is invalid because the resource already exists and can't be replaced. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_DENIED() = 9` The requested operation is denied for the caller. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_INTERNAL_ERROR() = 2` An internal error occurred within AppSearch, which the caller cannot address. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_INVALID_ARGUMENT() = 3` The caller supplied invalid arguments to the call. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_INVALID_SCHEMA() = 7` The caller supplied a schema which is invalid or incompatible with the previous schema. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_IO_ERROR() = 4` An issue occurred reading or writing to storage. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_NOT_FOUND() = 6` An entity the caller requested to interact with does not exist in the system. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_OK() = 0` The call was successful. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_OUT_OF_SPACE() = 5` Storage is out of space, and no more space could be reclaimed. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_RATE_LIMITED() = 10` The caller has hit AppSearch's rate limit and the requested operation has been rejected. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_SECURITY_ERROR() = 8` The caller requested an operation it does not have privileges for. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_UNAVAILABLE() = 14` An error occurred due to AppSearch not having the necessary resources to execute the API call. |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_UNKNOWN_ERROR() = 1` An unknown error occurred while processing the call. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#equals(java.lang.Object)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getErrorMessage()()` Returns the error message associated with this result. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()()` Returns one of the `RESULT` constants defined in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`. |
| `ValueType?` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultValue()()` Returns the result value associated with this result, if it was successful. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#hashCode()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#isSuccess()()` Returns `true` if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()` equals `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_OK()`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult<ValueType!>` | `<ValueType> https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#newFailedResult(int,java.lang.String)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, errorMessage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)` Creates a new failed `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`. |
| `java-static https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult<ValueType!>` | `<ValueType> https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#newSuccessfulResult(ValueType)(value: ValueType?)` Creates a new successful `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#toString()()` |

## Constants

### RESULT_ABORTED

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

```
@ExperimentalAppSearchApi
const val RESULT_ABORTED = 13: Int
```

The operation is aborted because an internal state change invalidated the results of the request. New requests should be able to process correctly and callers may, therefore, wish to retry.

Note: if retrying, the caller should restart the request at the topmost API level. For example, if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResults#getNextPageAsync()` throws an exception with code `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_ABORTED()`, then the caller should restart the search via `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession#search(java.lang.String,androidx.appsearch.app.SearchSpec)` API with a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResults` object, instead of calling `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResults#getNextPageAsync()` again with the original `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResults` object.

### RESULT_ALREADY_EXISTS

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

```
@ExperimentalAppSearchApi
const val RESULT_ALREADY_EXISTS = 12: Int
```

The operation is invalid because the resource already exists and can't be replaced.

### RESULT_DENIED

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

```
@ExperimentalAppSearchApi
const val RESULT_DENIED = 9: Int
```

The requested operation is denied for the caller. This error is logged and returned for denylist rejections.

### RESULT_INTERNAL_ERROR

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

```
const val RESULT_INTERNAL_ERROR = 2: Int
```

An internal error occurred within AppSearch, which the caller cannot address. This error may be considered similar to `https://developer.android.com/reference/java/lang/IllegalStateException.html`

### RESULT_INVALID_ARGUMENT

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

```
const val RESULT_INVALID_ARGUMENT = 3: Int
```

The caller supplied invalid arguments to the call. This error may be considered similar to `https://developer.android.com/reference/java/lang/IllegalArgumentException.html`.

### RESULT_INVALID_SCHEMA

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

```
const val RESULT_INVALID_SCHEMA = 7: Int
```

The caller supplied a schema which is invalid or incompatible with the previous schema.

### RESULT_IO_ERROR

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

```
const val RESULT_IO_ERROR = 4: Int
```

An issue occurred reading or writing to storage. The call might succeed if repeated. This error may be considered similar to `https://developer.android.com/reference/java/io/IOException.html`.

### RESULT_NOT_FOUND

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

```
const val RESULT_NOT_FOUND = 6: Int
```

An entity the caller requested to interact with does not exist in the system.

### RESULT_OK

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

```
const val RESULT_OK = 0: Int
```

The call was successful.

### RESULT_OUT_OF_SPACE

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

```
const val RESULT_OUT_OF_SPACE = 5: Int
```

Storage is out of space, and no more space could be reclaimed.

### RESULT_RATE_LIMITED

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

```
@ExperimentalAppSearchApi
const val RESULT_RATE_LIMITED = 10: Int
```

The caller has hit AppSearch's rate limit and the requested operation has been rejected. The caller is recommended to reschedule tasks with exponential backoff.

### RESULT_SECURITY_ERROR

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

```
const val RESULT_SECURITY_ERROR = 8: Int
```

The caller requested an operation it does not have privileges for.

### RESULT_UNAVAILABLE

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

```
@ExperimentalAppSearchApi
const val RESULT_UNAVAILABLE = 14: Int
```

An error occurred due to AppSearch not having the necessary resources to execute the API call.

### RESULT_UNKNOWN_ERROR

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

```
const val RESULT_UNKNOWN_ERROR = 1: Int
```

An unknown error occurred while processing the call.

## Public functions

### equals

```
fun equals(other: Any?): Boolean
```

### getErrorMessage

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

```
fun getErrorMessage(): String?
```

Returns the error message associated with this result.

If `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#isSuccess()` is `true`, the error message is always `null`. The error message may be `null` even if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#isSuccess()` is `false`. See the documentation of the particular `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession` call producing this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult` for what is returned by `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getErrorMessage()`.

### getResultCode

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

```
fun getResultCode(): Int
```

Returns one of the `RESULT` constants defined in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`.

### getResultValue

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

```
fun getResultValue(): ValueType?
```

Returns the result value associated with this result, if it was successful.

See the documentation of the particular `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchSession` call producing this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult` for what is placed in the result value by that call.

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if this `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult` is not successful. |

### hashCode

```
fun hashCode(): Int
```

### isSuccess

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

```
fun isSuccess(): Boolean
```

Returns `true` if `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()` equals `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#RESULT_OK()`.

### newFailedResult

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

```
java-static fun <ValueType> newFailedResult(resultCode: Int, errorMessage: String?): AppSearchResult<ValueType!>
```

Creates a new failed `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`.

| Parameters |
|---|---|
| `resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | One of the constants documented in `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult#getResultCode()`. |
| `errorMessage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | An optional string describing the reason or nature of the failure. |

### newSuccessfulResult

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

```
java-static fun <ValueType> newSuccessfulResult(value: ValueType?): AppSearchResult<ValueType!>
```

Creates a new successful `https://developer.android.com/reference/kotlin/androidx/appsearch/app/AppSearchResult`.

| Parameters |
|---|---|
| `value: ValueType?` | An optional value to associate with the successful result of the operation being performed. |

### toString

```
fun toString(): String
```