Using the range query
All the previous queries work with defined or partially defined values, but it's very common in a real-world application to work for a range of values. The most common standard scenarios are as follows:
- Filtering by numeric value range (that is, price, size, and age).
- Filtering by date (that is, the events of
03/07/12
can be a range query from03/07/12 00:00:00
to03/07/12 24:59:59
). - Filtering by term range (that is, from A to D).
Getting ready
You will need an up-and-running Elasticsearch installation, as described in the Downloading and installing Elasticsearch recipe of Chapter 1, Getting Started.
To execute the commands, any HTTP client can be used, such as Curl (https://curl.haxx.se/), Postman (https://www.getpostman.com/), or similar. I suggest you use the Kibana console as it provides code completion and better character escaping for Elasticsearch.
To correctly execute the following commands...