Use one aggregation to calculate another and return only the required aggregation

I am using a sum aggregation to find the minimum of all the sums.

GET /prod*/_search
{
  "size": 0, 
  "aggs": {
    "buckets": {
      "terms": {
        "field": "city.keyword",
        "size": 10
      },
      "aggs": {
        "city_views": {
          "sum": {
            "field": "View"
          }
        }
      }
    },
    "min_city_view": {
      "min_bucket": {
        "buckets_path": "buckets>city_views"
      }
    }
  }
}

I only want it to return the minimum value, not the sum aggregations(so that I can reduce the data transfer from server), how is it possible?

May be this could help: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.