# SearchResult.Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# Builder

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/app/appsearch/SearchResult.Builder "View this page in Java")  

```
class Builder
```

|---|------------------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                                           ||
| ↳ | [android.app.appsearch.SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) |

Builder for[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult)objects.

## Summary

|                                                                                                                                                                                                                                      Public constructors                                                                                                                                                                                                                                       ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#Builder(kotlin.String,%20kotlin.String))`(`packageName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`, `databaseName:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)`)` Constructs a new builder for[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult)objects. |

|                                                                                                                                                                                                                                                                                                                                                                             Public methods                                                                                                                                                                                                                                                                                                                                                                             ||
|--------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | [addInformationalRankingSignal](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#addInformationalRankingSignal(kotlin.Double))`(`rankingSignal:` `[Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)`)` Adds the informational ranking signal of the matched document in this SearchResult.                                                                                                                                                                                                                                                                                 |
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | [addJoinedResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#addJoinedResult(android.app.appsearch.SearchResult))`(`joinedResult:` `[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult)`)` Adds a[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult)that was joined by the[JoinSpec](https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec).                                                                                                                                    |
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | [addMatchInfo](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#addMatchInfo(android.app.appsearch.SearchResult.MatchInfo))`(`matchInfo:` `[SearchResult.MatchInfo](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchInfo)`)` Adds another match to this SearchResult.                                                                                                                                                                                                                                                                                              |
| [SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult)                  | [build](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#build())`()` Constructs a new[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult).                                                                                                                                                                                                                                                                                                                                                                                                                  |
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | [setGenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#setGenericDocument(android.app.appsearch.GenericDocument))`(`document:` `[GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument)`)` Sets the document which matched.                                                                                                                                                                                                                                                                                                                |
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | [setParentTypeMap](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#setParentTypeMap(kotlin.collections.MutableMap))`(`parentTypeMap:` `[MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!,` `[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!>!>`)` Sets the map from schema type names to the list of their parent types. |
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | [setRankingSignal](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#setRankingSignal(kotlin.Double))`(`rankingSignal:` `[Double](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-double/index.html)`)` Sets the ranking signal of the matched document in this SearchResult.                                                                                                                                                                                                                                                                                                                         |

## Public constructors

### Builder

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

Constructs a new builder for[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult)objects.

|                                                                                   Parameters                                                                                    ||
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `packageName`  | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the package name the matched document belongs to This value cannot be`null`.   |
| `databaseName` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html):the database name the matched document belongs to. This value cannot be`null`. |

## Public methods

### addInformationalRankingSignal

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 16](https://developer.android.com/sdkExtensions)  

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

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

|                                                                     Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | This value cannot be`null`. |

### addJoinedResult

Added in[API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 7](https://developer.android.com/sdkExtensions)  

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

Adds a[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult)that was joined by the[JoinSpec](https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec).

|                                                                                  Parameters                                                                                   ||
|----------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `joinedResult` | [SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult):The joined SearchResult to add. This value cannot be`null`. |

|                                                                     Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | This value cannot be`null`. |

### addMatchInfo

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

Adds another match to this SearchResult.

|                                                                           Parameters                                                                           ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| `matchInfo` | [SearchResult.MatchInfo](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.MatchInfo):This value cannot be`null`. |

|                                                                     Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | This value cannot be`null`. |

### build

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

Constructs a new[SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult).

|                                                             Return                                                             ||
|---------------------------------------------------------------------------------------------------|-----------------------------|
| [SearchResult](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult) | This value cannot be`null`. |

### setGenericDocument

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

Sets the document which matched.

|                                                                   Parameters                                                                    ||
|------------|-------------------------------------------------------------------------------------------------------------------------------------|
| `document` | [GenericDocument](https://developer.android.com/reference/kotlin/android/app/appsearch/GenericDocument):This value cannot be`null`. |

|                                                                     Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | This value cannot be`null`. |

### setParentTypeMap

Added in[API level 36](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Also in[T Extensions 17](https://developer.android.com/sdkExtensions)  

```
fun setParentTypeMap(parentTypeMap: MutableMap<String!, MutableList<String!>!>): SearchResult.Builder
```

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

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

Child types must appear before parent types in each list. Otherwise, the GenericDocument's toDocumentClass method (an AndroidX-only API) 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.

|                                                                                                                                                                                                              Parameters                                                                                                                                                                                                               ||
|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `parentTypeMap` | [MutableMap](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!,[MutableList](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index.html)\<[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!\>!\>:This value cannot be`null`. |

|                                                                     Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | This value cannot be`null`. |

### setRankingSignal

Added in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

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

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

|                                                                     Return                                                                      ||
|--------------------------------------------------------------------------------------------------------------------|-----------------------------|
| [SearchResult.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResult.Builder#) | This value cannot be`null`. |