Reputation: 5176
I want to sort my solr queries using a rather complex formula. I think I can get it to work by setting the right function in the sort parameter of the query, but I would like to check my work by seeing the explicit value of the function for each document.
I would like to do this by including the computed value as a field in the result, and then just sorting on that field. Is this the right approach, and if so how can I do this, or is there another approach? I have tried enabling debugquery, but I think it only explains the relevancy score, not the value that was used to sort the results.
In the admin dashboard, my solr-spec and lucene-spec are both 4.5.0
Upvotes: 0
Views: 168
Reputation: 11013
Use function query.
You can use the LocalParams syntax i.e. {!func}
or set defType=func
. (You may not want to use _val_
hook, since your function value then becomes a component in the score.) The score is the value of the function, so your results are automatically sorted by the function value. Fetch the score with fl=*,score
.
Upvotes: 2