# SearchResult.Builder

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

*** ** * ** ***


```
class SearchResult.Builder
```

<br />

*** ** * ** ***

Builder for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult` objects.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#Builder(java.lang.String,java.lang.String)(packageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, databaseName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Constructs a new builder for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult` objects. |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#addInformationalRankingSignal(double)(rankingSignal: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Adds the informational ranking signal of the matched document in this SearchResult. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#addJoinedResult(androidx.appsearch.app.SearchResult)(joinedResult: https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult)` Adds a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult` that was joined by the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#addMatchInfo(androidx.appsearch.app.SearchResult.MatchInfo)(matchInfo: https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.MatchInfo)` Adds another match to this SearchResult. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#build()()` Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult`. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#setDocument(java.lang.Object)(document: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)` Sets the document which matched. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#setGenericDocument(androidx.appsearch.app.GenericDocument)(document: https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument)` Sets the document which matched. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder` | `@https://developer.android.com/reference/kotlin/androidx/appsearch/app/ExperimentalAppSearchApi https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#setParentTypeMap(java.util.Map<java.lang.String,java.util.List<java.lang.String>>)( parentTypeMap: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!>!> )` Sets the map from schema type names to the list of their parent types. |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.Builder#setRankingSignal(double)(rankingSignal: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)` Sets the ranking signal of the matched document in this SearchResult. |

## Public constructors

### Builder

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

```
Builder(packageName: String, databaseName: String)
```

Constructs a new builder for `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult` objects.

| Parameters |
|---|---|
| `packageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the package name the matched document belongs to |
| `databaseName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the database name the matched document belongs to. |

## Public functions

### addInformationalRankingSignal

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

```
fun addInformationalRankingSignal(rankingSignal: Double): SearchResult.Builder
```

Adds the informational ranking signal of the matched document in this SearchResult.

### addJoinedResult

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

```
fun addJoinedResult(joinedResult: SearchResult): SearchResult.Builder
```

Adds a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult` that was joined by the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/JoinSpec`.

| Parameters |
|---|---|
| `joinedResult: https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult` | The joined SearchResult to add. |

### addMatchInfo

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

```
fun addMatchInfo(matchInfo: SearchResult.MatchInfo): SearchResult.Builder
```

Adds another match to this SearchResult.

### build

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

```
fun build(): SearchResult
```

Constructs a new `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult`.

### setDocument

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

```
fun setDocument(document: Any): SearchResult.Builder
```

Sets the document which matched.

| Parameters |
|---|---|
| `document: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html` | An instance of a class annotated with `https://developer.android.com/reference/kotlin/androidx/appsearch/annotation/Document`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/exceptions/AppSearchException` | if an error occurs converting a document class into a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`. |

### setGenericDocument

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

```
fun setGenericDocument(document: GenericDocument): SearchResult.Builder
```

Sets the document which matched.

### setParentTypeMap

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

```
@ExperimentalAppSearchApi
fun setParentTypeMap(
    parentTypeMap: (Mutable)Map<String!, (Mutable)List<String!>!>
): SearchResult.Builder
```

Sets the map from schema type names to the list of their parent types.

The map should include entries for the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument`'s own type and all of the nested documents' types.

Child types must appear before parent types in each list. Otherwise, the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/GenericDocument#toDocumentClass(java.lang.Class<T>,androidx.appsearch.app.DocumentClassMappingContext)` method may not correctly identify the most concrete type. This could lead to unintended deserialization into a more general type instead of a more specific type.

Parent types should include transitive parents.

### setRankingSignal

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

```
fun setRankingSignal(rankingSignal: Double): SearchResult.Builder
```

Sets the ranking signal of the matched document in this SearchResult.