How to set the number of intervals in the elasticsearch histogram

Using elasticsearch, I would like to get the histogram face for the price field in my model. Without knowing the minimum and maximum prices in advance, I would like the histogram to cover the entire price range with a given number of intervals, say 10. I can see from the documentation in

http://www.elasticsearch.org/guide/reference/api/search/facets/histogram-facet.html

that I can specify a price range for each interval, but that will give me some indefinite number of intervals. I would like to have a certain number of intervals that uniformly cover the entire range of values ​​for the price field. Is there any way to do this?

I know that one solution would be to query my database for min and max values ​​and then figure out the size of the corresponding interval, but this contradicts one of the main points of using elasticsearch, which should not hit db for search related queries.

+4
source share
2 answers

You can request elasticsearch for minimum and maximum values ​​using Statistical Fax

+1
source

You can track the progress in implementing this feature, called auto_histogramat https://github.com/elastic/elasticsearch/issues/31828.

0
source

All Articles