too_many_buckets_exception in elasticsearch too_many_buckets_exception in elasticsearch elasticsearch elasticsearch

too_many_buckets_exception in elasticsearch


Incase you are using ES version 7.x.x then you can add terminate_after clause to your query to limit the number of buckets into which the data would be divided into. This happens mostly when the data your are trying to aggregate has a high degree of randomness.

If your data contains text then it would better to aggregate on .keyword field (assuming you are using default settings).

POST your_index/_search{  "from": 0,  "query": {    "match_all": {}  },  "size": 0,  "sort": [    {      "your_target_field": {        "order": "desc"      }    }  ],  "terminate_after": 10000,  "version": true,  "aggs": {    "title": {      "terms": {        "field": "your_target_field.keyword",        "size": 10000      }    }  }}