Apache Solr: sort by one of fields (with condition)

前端 未结 1 1717
执念已碎
执念已碎 2021-01-22 16:52

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

相关标签:
1条回答
  • 2021-01-22 17:15

    As already pointed in this SO question

    try to use something like this for int fields :

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

    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

    0 讨论(0)
提交回复
热议问题