4
votes

The Elasticsearch range aggreagtion aggregates the data within given ranges ie

*GET /_search*
{
    "aggs" : {
        "price_ranges" : {
            "range" : {
                "field" : "price",
                "ranges" : [
                    { "to" : 100.0 },
                    { "from" : 100.0, "to" : 200.0 },
                    { "from" : 200.0 }
                ]
            }
        }
    }
}

but it doesnt mention if it is inclusive of the values ie if the bucket has documents with values inclusive of 100 and 200 or only those $gt 100 and $lt 200.

The following discussion states of a similar doubt but that too is inconclusive https://github.com/elastic/elasticsearch/issues/17079

TL:DR Does range aggregation support $lte & $gte or $gt & $lt and is there a way to aggregate according to usecase?

1

1 Answers

7
votes

"Note that this aggregation includes the from value and excludes the to value for each range"

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-range-aggregation.html