We are looking for a way of simulating sql "having" on Elasticsearch - i.e. to filter aggregated data based on the aggregated value.
Some of the previous replies on this issue referenced bucket selector - however, since bucket selector works only on the results of the terms aggregation it is not good enough for our case as there can be a large size of potential buckets.
Denormalizing the data in advance is also not an option in our case as we need to run the aggregations with different filters on the raw documents.
Currently we are considering using composite aggregation to page through all potential buckets.
Is there a better way to get the filtered buckets?