How can I sort solr result bases on dynamic fields

后端 未结 1 1474
野的像风
野的像风 2021-01-14 05:46

I need to sort result on the basis of dynamic field. How can I do that? When I am sorting on minimum value of some of those dynamic attribute. It\'s not giving correct resul

相关标签:
1条回答
  • 2021-01-14 06:34

    If you do not know if the field exist, you can set a default value in case it does not exists.

    Try to use the def function, that returns a default vlaue if the field does not exist.

    //in this part of query, I have put a default value that is very high in order to put the result on bottom of the list &sort=min(def(A_160018,9000000),def(A_chandigarh1,9000000))

    Extract of solr def doc

    def(field|function,defaultValue) returns the value of field "field", or if the field does not exist, returns the defaultValue specified.

    Example use: def(rating,5) The def() function will here return the rating, or if no rating specified in the doc, returns 5

    See reference solr documentation

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