Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is elasticsearch Range aggregation inclusive

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?

like image 964
anubysh Avatar asked Jan 27 '23 18:01

anubysh


1 Answers

"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

like image 157
LeBigCat Avatar answered Feb 04 '23 09:02

LeBigCat