SORL facet fields order by descending value

匆匆过客 提交于 2019-12-11 05:26:18

问题


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:


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”



来源:https://stackoverflow.com/questions/45346301/sorl-facet-fields-order-by-descending-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!