I want to eliminate all empty buckets from a range aggregation.
According to https://github.com/elastic/elasticsearch/issues/10027 the Bucket Selector Pipeline Aggregation is the way to go, but I'm struggling with its syntax. Here's what I have so far:
{
"aggs": {
"values_histogram": {
"range": {
"field": "value",
"ranges": [
{ "from": 1, "to": 2 },
{ "from": 2, "to": 3 },
{ "from": 3, "to": 4 }
]
},
"aggs": {
"the_filter": {
"bucket_selector": {
"buckets_path": {
"the_doc_count": "values_histogram.doc_count"
},
"script": "the_doc_count > 0"
}
}
}
}
}
}
But this gives me the error:
No aggregation found for path [values_histogram.doc_count]