Searching/filtering by range is a very common scenario in a real world application. Some standard cases are as follows:
You need a working ElasticSearch cluster, an index "test
" (refer to the next chapter to learn how to create an index), and basic knowledge of JSON.
For executing a range query/filter, we need to perform the following step:
Considering the sample data of previous examples which contains an integer field
position
. Using it to execute a query for filtering positions between3
and5
, we will have:curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "filtered": { "filter": { "range" : { "position" : { ...