Using the range query
In every application, it's very common to search a range of values. The most common standard scenarios are:
Filtering by numeric value range (that is, price, size, and age)
Filtering by date (that is, 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 need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
To execute curl
via the command line, you need to install curl
for your operative system.
To correctly execute the following commands, you need an index populated with the chapter_05/populate_query.sh
script available in the online code.
How to do it...
For executing a range query, we will perform the following steps:
Consider the sample data of the previous examples, which contains an integer field
position
; using it to execute a query for filtering positions between3
and5
...