range-query.asciidoc 840 B

12345678910111213141516171819202122232425262728293031
  1. [[query-dsl-range-query]]
  2. === Range Query
  3. Matches documents with fields that have terms within a certain range.
  4. The type of the Lucene query depends on the field type, for `string`
  5. fields, the `TermRangeQuery`, while for number/date fields, the query is
  6. a `NumericRangeQuery`. The following example returns all documents where
  7. `age` is between `10` and `20`:
  8. [source,js]
  9. --------------------------------------------------
  10. {
  11. "range" : {
  12. "age" : {
  13. "gte" : 10,
  14. "lte" : 20,
  15. "boost" : 2.0
  16. }
  17. }
  18. }
  19. --------------------------------------------------
  20. The `range` query accepts the following parameters:
  21. [horizontal]
  22. `gte`:: Greater-than or equal to
  23. `gt`:: Greater-than
  24. `lte`:: Less-than or equal to
  25. `lt`:: Less-than
  26. `boost`:: Sets the bool value of the query, defaults to `1.0`