问题
So here is what I am trying to do. I have a facet defined on the price field.
1) When there is a query for "wordA" I want the facets to be from 0-1000 divided in 5 intervals since my maximum price for "wordA" will never exceed 1000
2) When there is a query for "wordB" I want the facets to be from 0-50 divided in 5 intervals since my maximum price for the query "wordB" will never exceed 50.
So basically I want the facet range to change dynamically so that I don't end up with a range of 0-1000 for a query "wordB" where all the hits will lie in the 1st range.
If solr does not support this then it will be a lot of query post processing involved to modify the ranges based on the returned results.
回答1:
Solr does not support that, but you can do it yourself by doing two queries - first get the stats (max, min) for the field, then submit a query for the facet ranges (intervals) that are suitable for your application.
来源:https://stackoverflow.com/questions/33179596/solr-range-facets-dynamically-modifying-the-ranges-based-on-the-search-query