首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Solrconfig中使用lst=invariants对多个字段进行排序

在Solrconfig中使用lst=invariants对多个字段进行排序
EN

Stack Overflow用户
提问于 2015-03-26 13:12:53
回答 1查看 133关注 0票数 0

我试图通过在Solrconfig文件中更改以下内容,在Solr中对类型为date的ABC和类型为text的XYZ两个不同的字段应用排序:

代码语言:javascript
复制
<requestHandler name="/select" class="solr.SearchHandler">
  <lst name="invariants">
  <str name="sort">ABC desc</str>
  <str name="sort">XYZ desc</str> 
</lst>

我希望按照ABC字段排序,但如果任何记录有相同的日期,排序应该是按照XYZ字段。根据我的代码,我得到的结果只有ABC字段。

EN

回答 1

Stack Overflow用户

发布于 2015-03-26 19:58:51

Solr's reference documentation and there the part about sorting中,您可以读取

  • 多个排序顺序可以用逗号分隔,使用以下语法: sort=+,+],...

代码语言:javascript
复制
- When more than one sort criteria is provided, the second entry will only be used if the first entry results in a tie. If there is a third entry, it will only be used if the first AND second entries are tied. This pattern continues with further entries.

但是您已经为该字段传递了两个单独的参数,因此请尝试按照说明进行传递,并用逗号分隔它们

代码语言:javascript
复制
<requestHandler name="/select" class="solr.SearchHandler">
  <lst name="invariants">
  <str name="sort">ABC desc,XYZ desc</str>
</lst>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29271523

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档