1
votes

I have recently started using Solr and I have a use-case where, in the facet results I need the counts of ranges from start but not just for sub-ranges. For example, lets say I want to get the counts for all items with rating between (0-1), (0-2), (0-3), (0-4), (0-5) instead of (0-1), (1-2), (2-3), (3-4), (4-5) I was planning on using "&facet=on&facet.field=rating&facet.rating.start=0&facet.rating.end=5&facet.rating.gap=1", but this gives the counts for (0-1), (1-2), (2-3), (3-4), (4-5) instead.

Is there any way to make Solr directly return counts in the way that I specified? This seems like a fairly popular requirement.

1

1 Answers

1
votes

You can't do that using facet ranges (yet), but you can try with arbitrary facet queries :

facet.query={!key='0-1'}rating:[0 TO 1]&
facet.query={!key='0-2'}rating:[0 TO 2]&
facet.query={!key='0-3'}rating:[0 TO 3]&
facet.query={!key='0-4'}rating:[0 TO 4]&
facet.query={!key='0-5'}rating:[0 TO 5]