# Is there SDK support for addin boosting in elasticsearch-java?

**URL:** <https://discuss.elastic.co/t/is-there-sdk-support-for-addin-boosting-in-elasticsearch-java/374416>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [February 12, 2025, 10:03am UTC](https://discuss.elastic.co/t/is-there-sdk-support-for-addin-boosting-in-elasticsearch-java/374416 "2025-02-12T10:03:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hans\_Kruse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hans_kruse/32/54739_2.png) [@Hans\_Kruse](https://discuss.elastic.co/u/Hans_Kruse)\
**Post date:** [February 12, 2025, 10:03am UTC](https://discuss.elastic.co/t/is-there-sdk-support-for-addin-boosting-in-elasticsearch-java/374416/1 "2025-02-12T10:03:37Z")

</div>

Is there SDK support for addin boosting in elasticsearch-java?

In the 7.x SDK there was a field method on the `MultiMatchQueryBuilder` to set both the field name as wel as a boost value.

In the following code Field is a DTO containing both a field name and a boost value.

```Java
....
    private MultiMatchQueryBuilder addFields(MultiMatchQueryBuilder builder, Set<Field> fields) {
        fields.stream().filter(Field::isIndexed).forEach(field -> builder.field(field.getName(), field.getBoost()));
        return builder;
    }

```

In 8.x this functionality is missing.

What I do now is using a `String.format(...)` to get the boost in:

```Java
private @NotNull MultiMatchQuery.Builder createTermMatcher(
        final @NotNull String terms,
        final @NotNull Set<Field> fields) {
        return new MultiMatchQuery.Builder()
            .query(terms)
            .fields(fields
                .stream()
                .filter(Field::isIndexed)
                .map(field -> String.format("%s^%s", 
                    field.getName(),
                   field.getBoost()))
                .toList())
            .operator(Operator.And);
    }

```

Is there another way of doing this with the `elastic-search` Java-SDK ?

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [February 12, 2025, 3:05pm UTC](https://discuss.elastic.co/t/is-there-sdk-support-for-addin-boosting-in-elasticsearch-java/374416/2 "2025-02-12T15:05:34Z")

</div>

Your approach is correct, the Java API client has no helper method to combine field name and boost like the 7.x client.
