How to query elasticsearch for greater than and less than?

Returns documents where the price value between 1000 and 2000 inclusive.

{
    "query": {
        "range" : {
            "price" : {
                "gte" : 1000,
                "lte" : 2000
            }
        }
    }
}

Range Query

Matches documents with fields that have terms within a certain range.
The type of the Lucene query depends on the field type, for string
fields, the TermRangeQuery, while for number/date fields, the query is
a NumericRangeQuery.

gte – Greater-than or equal to

lte – Less-than or equal to

gt – Greater-than

lt – Less-than

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)