elasticsearchrange-query

Are "from" and "gte"/"gt" equivalent in range query in ElasticSearch?


I've just discovered that a package that I use for ElasticSearch operations https://github.com/olivere/elastic creates the following range queries with from, to, include_lower and include_upper tags:

"query": {
    "range": {
        "myfield": {
            "from": 0.6666,
            "include_lower": true,
            "include_upper": true,
            "to": null
        }
    }
}

Whereas ES documentation states that the following should be used.

"query": {
    "range": {
        "myfield": {
            "gte": 0.6666
        }
    }
}

To my surprise the former (undocumented) works the same way as the latter. Are they equivalent? Should I expect that to work in the long run? Is that specified somewhere in ES?


Solution

  • The old format for range queries (using from/to/include_upper/include_lower) has been deprecated for serveral range queries in 0.90.4

    And there are plans to remove support for the deprecated notation: https://github.com/elastic/elasticsearch/issues/48538#issuecomment-552642795

    So if you don't like surprises, refactor the queries to the official range query notation.