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)

# Builder

*** ** * ** ***

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

```
class Builder
```

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

Builder for `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec`.

## Summary

| Public constructors ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#Builder(android.app.appsearch.JoinSpec)(joinSpec: https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec)` Creates a new `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#` from the given `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec`. |
| `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#Builder(kotlin.String)(childPropertyExpression: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Create a specification for the joining operation in search. |

| Public methods ||
|---|---|
| [JoinSpec](https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec) | `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#build()()` Constructs a new `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec` from the contents of this builder. |
| [JoinSpec.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#setAggregationScoringStrategy(kotlin.Int)(aggregationScoringStrategy: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets how we derive a single score from a list of joined documents. |
| [JoinSpec.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#setChildPropertyExpression(kotlin.String)(childPropertyExpression: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)` Sets the child property expression. |
| [JoinSpec.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#setMaxJoinedResultCount(kotlin.Int)(maxJoinedResultCount: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)` Sets the max amount of `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResults` to return with the parent document, with a default of 10 SearchResults. |
| [JoinSpec.Builder](https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#) | `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#setNestedSearch(kotlin.String,%20android.app.appsearch.SearchSpec)(nestedQuery: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, nestedSearchSpec: https://developer.android.com/reference/kotlin/android/app/appsearch/SearchSpec)` Sets the query and the SearchSpec for the documents being joined. |

## Public constructors

### Builder

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

```
Builder(joinSpec: JoinSpec)
```

Creates a new `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#` from the given `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec`.

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

### Builder

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)

```
Builder(childPropertyExpression: String)
```

Create a specification for the joining operation in search.

The child property expression specifies how to join documents. Documents with a child property expression equal to the qualified id of the parent will be retrieved.

Property expressions differ from `https://developer.android.com/reference/kotlin/android/app/appsearch/PropertyPath` as property expressions may refer to document properties or nested document properties such as "person.business.id" as well as a property expression. Currently the only property expression is "this.qualifiedId()". `https://developer.android.com/reference/kotlin/android/app/appsearch/PropertyPath` objects may only reference document properties and nested document properties.

In order to join a child document to a parent document, the child document must contain the parent's qualified id at the property expression specified by this method.

| Parameters ||
|---|---|
| `childPropertyExpression` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): the property to match in the child documents. This value cannot be `null`. |

## Public methods

### build

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 build(): JoinSpec
```

Constructs a new `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec` from the contents of this builder.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec` | This value cannot be `null`. |

### setAggregationScoringStrategy

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 setAggregationScoringStrategy(aggregationScoringStrategy: Int): JoinSpec.Builder
```

Sets how we derive a single score from a list of joined documents.

The default scoring strategy is `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_OUTER_RESULT_RANKING_SIGNAL:kotlin.Int`, which specifies that the ranking signal of the outer parent document will be used.

| Parameters ||
|---|---|
| `aggregationScoringStrategy` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Value is one of the following: - `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_OUTER_RESULT_RANKING_SIGNAL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_RESULT_COUNT:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_MIN_RANKING_SIGNAL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_AVG_RANKING_SIGNAL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_MAX_RANKING_SIGNAL:kotlin.Int` - `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_SUM_RANKING_SIGNAL:kotlin.Int` |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchSpec#RANKING_STRATEGY_JOIN_AGGREGATE_SCORE:kotlin.Int`

### setChildPropertyExpression

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 setChildPropertyExpression(childPropertyExpression: String): JoinSpec.Builder
```

Sets the child property expression.

The child property expression specifies how to join documents. Documents with a child property expression equal to the qualified id of the parent will be retrieved.

Property expressions differ from `https://developer.android.com/reference/kotlin/android/app/appsearch/PropertyPath` as property expressions may refer to document properties or nested document properties such as "person.business.id" as well as a property expression. Currently the only property expression is "this.qualifiedId()". `https://developer.android.com/reference/kotlin/android/app/appsearch/PropertyPath` objects may only reference document properties and nested document properties.

In order to join a child document to a parent document, the child document must contain the parent's qualified id at the property expression specified by this method.

| Parameters ||
|---|---|
| `childPropertyExpression` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): the property to match in the child documents. This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#` | This value cannot be `null`. |

### setMaxJoinedResultCount

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 setMaxJoinedResultCount(maxJoinedResultCount: Int): JoinSpec.Builder
```

Sets the max amount of `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchResults` to return with the parent document, with a default of 10 SearchResults.

This does NOT limit the number of results that are joined with the parent document for scoring. This means that, when set, only a maximum of `maxJoinedResultCount` results will be returned with each parent document, but all results that are joined with a parent will factor into the score.

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#` | This value cannot be `null`. |

### setNestedSearch

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 setNestedSearch(
    nestedQuery: String, 
    nestedSearchSpec: SearchSpec
): JoinSpec.Builder
```

Sets the query and the SearchSpec for the documents being joined. This will score and rank the joined documents as well as filter the joined documents.

If `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchSpec#RANKING_STRATEGY_JOIN_AGGREGATE_SCORE:kotlin.Int` is set in the outer `https://developer.android.com/reference/kotlin/android/app/appsearch/SearchSpec`, the resulting signals will be used to rank the parent documents. Note that the aggregation strategy also needs to be set with `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#setAggregationScoringStrategy(kotlin.Int)`, otherwise the default will be `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#AGGREGATION_SCORING_OUTER_RESULT_RANKING_SIGNAL:kotlin.Int`, which will just use the parent documents ranking signal.

If this method is never called, `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#getNestedQuery()` will return an empty string, meaning we will join with every possible document that matches the equality constraints and hasn't been filtered out by the type or namespace filters.

| Parameters ||
|---|---|
| `nestedQuery` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html): This value cannot be `null`. |
| `nestedSearchSpec` | [SearchSpec](https://developer.android.com/reference/kotlin/android/app/appsearch/SearchSpec): This value cannot be `null`. |

| Return ||
|---|---|
| `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec.Builder#` | This value cannot be `null`. |

**See Also**

- `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#getNestedQuery()`
- `https://developer.android.com/reference/kotlin/android/app/appsearch/JoinSpec#getNestedSearchSpec()`