How to perform a pipeline aggregation without returning all buckets in Elasticsearch How to perform a pipeline aggregation without returning all buckets in Elasticsearch elasticsearch elasticsearch

How to perform a pipeline aggregation without returning all buckets in Elasticsearch


I had the same issue and after doing quite a bit of research I found a solution and thought I'd share here.

You can use the Response Filtering feature to filter the part of the answer that you want to receive.

You should be able to achieve what you want by adding the query parameter filter_path=aggregations.avg_min_value to the search URL. In the example case, it should look similar to this:

curl -XPOST 'http://10.10.0.7:9200/test-index/obj/_search?filter_path=aggregations.avg_min_value' -d '{  "size": 0,  "query": {    "match_all": {}  },  "aggregations": {    "key_aggregates": {      "terms": {        "field": "key",        "size": 0      },      "aggs": {        "min_value": {          "min": {            "field": "value"          }        }      }    },    "avg_min_value": {      "avg_bucket": {        "buckets_path": "key_aggregates>min_value"      }    }  }}'

PS: if you found another solution would you mind sharing it here? Thanks!