# How to change the default size of MultiTermAggregation in Java

**URL:** <https://discuss.elastic.co/t/how-to-change-the-default-size-of-multitermaggregation-in-java/306424>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [June 6, 2022, 6:16am UTC](https://discuss.elastic.co/t/how-to-change-the-default-size-of-multitermaggregation-in-java/306424 "2022-06-06T06:16:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![good\_Royale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/good_royale/32/104980_2.png) [@good\_Royale](https://discuss.elastic.co/u/good_Royale)\
**Post date:** [June 6, 2022, 6:16am UTC](https://discuss.elastic.co/t/how-to-change-the-default-size-of-multitermaggregation-in-java/306424/1 "2022-06-06T06:16:55Z")

</div>

I was wondering if there is a way to change the default size in **MultiTermAggregation** in Java,  
I can change the default size in dev tools in kibana,  
but cannot change the size in java.

Query look like this

```json
GET test_index/_search
{
    "aggs": {
        "multi_terms": {
           "terms": [
             {
               "field": "attributes1"
             },
             {
               "field": "attributes2"
             }
           ],
           "size": 1000
        }
    }
}

```

And In java I want to define this size but I cannot  
Java code:

```java
List<MultiTermLookup> multiTermsList = new ArrayList<>();
multiTermsList.add(MultiTermLookup.of(mt -> mt
              .field("attributes1")
);
multiTermsList.add(MultiTermLookup.of(mt -> mt
              .field("attributes2")
);
Aggregation agg = Aggregation.of(a -> a
                                .multiTerms(mt -> mt
                                      .terms(multiTermsList)
                                      // .size(1000) this is not possible (says "cannot resolve size method in Builder")
                                );

```

Can you help me out to figure out how to do this, or suggest any other multiTerm aggregation class which also support child aggregation.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [June 6, 2022, 12:52pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-size-of-multitermaggregation-in-java/306424/2 "2022-06-06T12:52:10Z")

</div>

Hi!  
It seems that others are also having the same question.  
I believe that soon the parameters will be added.

> <https://github.com/elastic/elasticsearch-java/issues/250>
>
> \### Description
> 
> \### Java API client version: 8.1.3
> 
> No possibility to configu…re additional settings (like \*\*size\*\*) of multi terms aggregation requests in the java client.
> The list of such parameters you can see there:
> https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-multi-terms-aggregation.html#search-aggregations-bucket-multi-terms-aggregation-parameters

---

<div class="post-metadata">

**Author:** ![good\_Royale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/good_royale/32/104980_2.png) [@good\_Royale](https://discuss.elastic.co/u/good_Royale)\
**Post date:** [June 6, 2022, 1:04pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-size-of-multitermaggregation-in-java/306424/3 "2022-06-06T13:04:55Z")

</div>

Okay,  
Thank you 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 4, 2022, 1:05pm UTC](https://discuss.elastic.co/t/how-to-change-the-default-size-of-multitermaggregation-in-java/306424/4 "2022-07-04T13:05:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
