This question was originally posted on StackOverflow:
I'm having trouble with controlling the number of buckets an aggregation is going to create.
This is a simple aggregation containing no nested or sub aggregations on an index having roughly 80000
documents:
GET /my_index/_search
{
"size":0,
"query":{
"match_all":{}
},
"aggregations":{
"unique":{
"terms":{
"field":"_id",
"size":<NUM_TERM_BUCKETS>
}
}
}
}
If I set the <NUM_TERM_BUCKETS>
to 7000
, I get this error response in ES 7.3:
{
"error":{
"root_cause":[
{
"type":"too_many_buckets_exception",
"reason":"Trying to create too many buckets. Must be less than or equal to: [10000] but was [10001]. This limit can be set by changing the [search.max_buckets] cluster level setting.",
"max_buckets":10000
}
],
"type":"search_phase_execution_exception",
"reason":"all shards failed",
"phase":"query",
"grouped":true,
"failed_shards":[
{
"shard":0,
"index":"my_index",
"node":"XYZ",
"reason":{
"type":"too_many_buckets_exception",
"reason":"Trying to create too many buckets. Must be less than or equal to: [10000] but was [10001]. This limit can be set by changing the [search.max_buckets] cluster level setting.",
"max_buckets":10000
}
}
]
},
"status":503
}
And it runs successfully if I decrease the <NUM_TERM_BUCKETS>
to 6000
.
I'm really confused. how on earth this aggregation creates more than 10000
buckets?