# Aggregation exception

**URL:** https://discuss.elastic.co/t/aggregation-exception/171410
**Category:** Elasticsearch
**Created:** [March 8, 2019, 2:43am UTC](https://discuss.elastic.co/t/aggregation-exception/171410 "2019-03-08T02:43:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aniaks](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@aniaks](https://discuss.elastic.co/u/aniaks)
#### Post date: [March 8, 2019, 2:43am UTC](https://discuss.elastic.co/t/aggregation-exception/171410/1 "2019-03-08T02:43:33Z")

</div>

This aggregation creates too many buckets (10001) and will throw an error in future versions. You should update the [search.max\_buckets] cluster setting or use the [  
composite] aggregation to paginate all buckets in multiple requests.

We are using 6.2.2 version. Let us know what steps we should be doing to get away from this issue.

---

<div class="post-metadata">

### Author: ![ylasri](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ylasri/32/86120_2.png) [@ylasri](https://discuss.elastic.co/u/ylasri)
#### Post date: [March 8, 2019, 7:01am UTC](https://discuss.elastic.co/t/aggregation-exception/171410/2 "2019-03-08T07:01:40Z")

</div>

You can update the setting, refer to [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket.html)

```
PUT /_cluster/settings?flat_settings=true {
"transient" : {
    "search.max_buckets" : "100000"
   }
}

```

or using partitions in your query (I guess you are using Rest client ? )

```
  "aggs": {
"msisdn": {
  "terms": {
    "field": "bucket_term",
    "include": {
           "partition": 0,
           "num_partitions": 100
        },
    "size": 100000,
    "order": {
      "field_name": "desc"
    }
  }
```

---

<div class="post-metadata">

### Author: ![aniaks](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@aniaks](https://discuss.elastic.co/u/aniaks)
#### Post date: [March 8, 2019, 3:17pm UTC](https://discuss.elastic.co/t/aggregation-exception/171410/3 "2019-03-08T15:17:35Z")

</div>

thanks for your suggestion, will try this out.

---

<div class="post-metadata">

### Author: ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)
#### Post date: [March 8, 2019, 4:36pm UTC](https://discuss.elastic.co/t/aggregation-exception/171410/4 "2019-03-08T16:36:45Z")

</div>

Much can depend on what you are sorting by and data volumes.

This [wizard](https://embed.plnkr.co/zCPNM2OcM3lxEYg4M7rD/) I've been sketching out may help guide you to the right solution.

---

<div class="post-metadata">

### Author: ![aniaks](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@aniaks](https://discuss.elastic.co/u/aniaks)
#### Post date: [March 11, 2019, 4:41pm UTC](https://discuss.elastic.co/t/aggregation-exception/171410/5 "2019-03-11T16:41:31Z")

</div>

this helps. 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: [April 8, 2019, 4:41pm UTC](https://discuss.elastic.co/t/aggregation-exception/171410/6 "2019-04-08T16:41:34Z")

</div>

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