I'm facing an issue with a nested terms query.
We have documents with nested documents within and use multiple nested terms aggregations in our queries.
The cardinality of each text field is also quite high.
In order to get all the existing data we set the size parameter for each terms aggregation to 2147483647 (Integer.MAX)
Depending on the number of documents, these queries run forever and consume massive memory. Actually our ES cluster is not usable any longer and needs a restart.
When we decrease the value for the size parameters in the terms query, the query can be executed but fails with "too_many_buckets_exception".
This is absolutely fine for us, since we just want any kind of circuit breaker that prevents our cluster to crash.
Since the query would fail anyway with "too_many_buckets_exception", I wonder if there is any reason to set the size parameter for the terms queries greater than our configured search.max_buckets value +1 or even the cardinality for the specific term +1, if we knew the cardinality exactly.
Thanks for your ideas and hints