Apache Solr:按字段之一排序(带条件) [英] Apache Solr: sort by one of fields (with condition)

查看:20
本文介绍了Apache Solr:按字段之一排序(带条件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果文档中存在field1",我想添加排序,否则添加field2"排序.请帮助我查询语法.

I want to add sorting by "field1" if it's exists in document, and by "field2" if not. Help me please with query syntax.

推荐答案

正如在这个 SO 问题

尝试对 int 字段使用这样的东西:

try to use something like this for int fields :

sort=min(def(A_160018,9000000),def(A_chandigarh1,9000000))

对于字符串字段,选项是在核心/集合中使用包含字段串联的额外字段 - 例如fullname: lastname + ' ' + firstname 在创建文档时明确写在文档中.然后你仍然可以做 sort=fullname asc

For string fields the option would be to use in the core/collection an extra field containing the concatenation of the fields - e.g. fullname: lastname + ' ' + firstname written explicitly in the document when it is created. Then you can still do sort=fullname asc

这篇关于Apache Solr:按字段之一排序(带条件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆