2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-range-query]]
|
|
|
|
=== 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`. The following example returns all documents where
|
|
|
|
`age` is between `10` and `20`:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"range" : {
|
2013-09-12 09:07:15 -04:00
|
|
|
"age" : {
|
|
|
|
"gte" : 10,
|
|
|
|
"lte" : 20,
|
2013-08-28 19:24:34 -04:00
|
|
|
"boost" : 2.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2013-09-12 09:07:15 -04:00
|
|
|
The `range` query accepts the following parameters:
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2013-09-12 09:07:15 -04:00
|
|
|
[horizontal]
|
|
|
|
`gte`:: Greater-than or equal to
|
|
|
|
`gt`:: Greater-than
|
|
|
|
`lte`:: Less-than or equal to
|
|
|
|
`lt`:: Less-than
|
2014-03-26 09:51:02 -04:00
|
|
|
`boost`:: Sets the boost value of the query, defaults to `1.0`
|
2013-08-28 19:24:34 -04:00
|
|
|
|