Range query on the result of Sum aggregation


(Nikhil Nambiar) #1

I am trying to apply range on the result that I got from sum aggregation.
Below query helps me to find sum of amount of individual phone

{
  "size": 0,
  "aggs": {
    "group_by_phone": {
      "terms": {
        "field": "phone.keyword"
      },
      "aggs": {
        "total_call_amount": {
          "sum": {
            "field": "amount"
          }
        }
      }
    }
  }
}

Now I want to filter by applying range on total_call_amount which is summing above 8000.


(Zachary Tong) #2

The bucket_selector aggregation should work in this case. You can use it to filter out all buckets that have a total_call_amount < 8000


(system) #3

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