Wednesday, 18 November 2015

Elasticsearch: range query

Range query is used to perform operations like greater than(>), less than (<), greater than or equal to (>=) and less than or equal to (<=).

Range query accepts below parameters.

Parameter
Meaning
gte
Greater than or equal to
gt
Greater than
lte
Less than or equal to
lt
Less than


{
  "query":{
    "range" : {
      "age" : {
        "gte" : 10,
        "lte" : 20,
        "boost" : 2.0
        }
    }
  }
}

Above query return all documents where age is >= 10 and <= 20.

Note:
Range query also accepts ‘boost’ as parameter.  ‘boost’ parameter sets the boost value of the query, defaults to 1.0




Prevoius                                                 Next                                                 Home

No comments:

Post a Comment