SORL 构面字段按降序值排序

SORL facet fields order by descending value

我正在使用带有多面体过滤器的 SOLR 6.5.1。 我的查询有:

facet.limit=-1 --> 生成所有可能的分面值

facet.sort=index --> 不是按出现次数而是按值 itsef

对构面值进行排序

例如,一个方面具有整数作为值(特别是字段包含年份)。所以这些值是(出现在括号中):

2010 (438)

2011 (547)

...

2017 (367)

构面按值正确排序,但采用升序 (2010-->2017)。如何获得倒序(2017-->2010)?

谢谢

您将无法使用简单方面 API(直接在 URL 中使用的旧方面)指定排序方向。但是由于您正在检索所有可能的方面,因此您可以在输出值之前在客户端控制器中反转方向。具体如何操作取决于您使用的语言。

但是,如果您切换到 the more modern JSON-based facet API,则可以直接在构面的每个级别上指定排序顺序:

"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”