根据构面数量从最小到最大排序

问题描述

这是我的方面查询

http:// localhost:8983 / solr / test_words / select?q = *:*&facet = true&facet.field = keyword

搜索时,我会根据方面数从高到低排序结果

示例:{“和”:10,“收件人”:9,“也”:8}

但是我反而希望结果根据构面计数从最低到最高

示例:{“泰米尔语”:1,“英语”:2,“法语”:3}

我也尝试过

http:// localhost:8983 / solr / test_words / select?q = *:*&facet = true&facet.field = keyword&facet.sort = count

哪个没有给出预期的结果。请帮我!

解决方法

据我所知,“旧”构面界面不支持按asc进行排序-它总是从最常见的术语到最不常见的术语进行排序。

The JSON facet API确实支持ascdesc进行排序:

排序-指定如何对生成的存储桶进行排序。

count指定文档计数,index按存储桶值的索引(自然)顺序排序。也可以按存储桶中发生的任何方面功能/统计信息进行排序。默认值为count desc。此参数也可以在JSON中指定,例如sort:{count:desc}。排序顺序可以是ascdesc

  "facet": {
    keywords: {
      "type": "terms","field": "keyword","sort": "count asc","limit": 5
    }
  }

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...