June 2017
Beginner to intermediate
404 pages
8h 22m
English
Just like date range aggregation, range aggregation is used to define buckets based on the ranges specified. In the following example, we will use range aggregation to group the products based on the number of products sold. The query is as follows:
#Aggs bases on Filters POST chapter8/_search { "size": 0, "aggs": { "price_range": { "range": { "field": "products_sold", "ranges": [ { "to": "10" }, { "from": "10", "to": "20" }, { "from": "20" } ] } } } }
The response is as follows:
{ .... "hits": { "total": 5, "max_score": 0, "hits": [] }, "aggregations": { "price_range": { "buckets": [ { "key": "*-10.0", "to": 10, "doc_count": 0 }, { "key": "10.0-20.0", "from": 10, "to": 20, "doc_count": ...Read now
Unlock full access