2
votes

I am using SOLR 6.5.1 with facet filters. My query has:

facet.limit=-1 --> to generate all possible facets values

facet.sort=index --> to order facets values not by number of occurrences but by the value itsef

For instance, one facet has integers as values (in particular the fields contains years). So the values are (occurences in brackets):

2010 (438)

2011 (547)

...

2017 (367)

The facet is correctly ordered by value but with asc order (2010-->2017). How can obtaint the reverse order (2017-->2010)?

Thanks

UMG

1

1 Answers

1
votes

You won't be able to specify the sort direction with the simple facet API (the old one used directly in the URL). But since you're retrieving all the possible facets, you can reverse the direction in your client side controller before outputting the values. Exactly how you do that depends on which language you're using.

But if you'd switch over to the more modern JSON-based facet API, you can specify the sort order directly on each level of the facet:

"sort":"index desc"

Specifies how to sort the buckets produced. “count” specifies document count, “index” sorts by the index (natural) order of the bucket value. One can also sort by any facet function / statistic that occurs in the bucket. The default is “count desc”. This parameter may also be specified in JSON like sort:{count:desc}. The sort order may either be “asc” or “desc”