
ElasticSearch Cookbook
By :

Searching/filtering by range is a very common scenario in a real world application. Some standard cases are as follows:
Filtering by range numeric value (that is, Price, size, ages, and so on)
Filtering by date (that is, events of 03/07/12 can be a range query from 03/07/12 00:00:00 and 03/07/12 24:59:59)
Filtering by term (that is, from A
to D
)
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 between 3
and 5
, we will have:
curl -XPOST 'http://127.0.0.1:9200/test-index/test-type/_search' -d '{ "query": { "filtered": { "filter": { "range" : { "position" : { ...
Change the font size
Change margin width
Change background colour