问题
I have the following query where
- I execute a first term aggregation that returns a large number of buckets
- then execute a metric aggregation on this bucket (avg in this example)
- and finally a sum_bucket aggregation
When I run this query, the output contains all the intermediary my_huge_bucket.my_huge_bucket_metric results but I am only interested by the sum_bucket metric.
Is there a way to strip the intermediary aggregation from the result?
{
"size": 0,
"aggs": {
"my_sum_bucket": {
"sum_bucket": {
"buckets_path": "my_huge_bucket.my_huge_bucket_metric"
}
},
"my_huge_bucket": {
"terms": {
"field": "some_field",
"size": 0
},
"aggs": {
"my_huge_bucket_metric": {
"avg": {
"field": "some_field"
}
}
}
}
}
}
回答1:
Just found out about the filter_path options that does exactly what I am looking for
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/common-options.html#_response_filtering
来源:https://stackoverflow.com/questions/36361271/elasticsearch-sum-bucket-strip-intermediary-aggregation-from-result