Executing histogram facets
ElasticSearch numerical values can be used to process histogram data. The histogram representation of a facet is a very powerful way to show data to end-users.
Getting ready
You need a working ElasticSearch cluster and an index populated with the script available in online code.
How to do it...
For executing histogram facets, we will perform the steps given as follows:
Using the items populated with the script, we want to calculate facets on:
Age with interval of 5 years
Price with interval of $10
Date with interval of 6 months
The query will be:
curl -XGET 'http://127.0.0.1:9200/test-index/test-type/_search?pretty=true&size=0' -d '{ "query": { "match_all": {} }, "facets": { "age" : { "histogram" : { "field" : "age", "interval" : 5 } }, "price" : { "histogram" : { "field" : "price", "interval" : 10.0 } }...