1

I need to sort documents returned in order of (descending) score & (descending) value of an int field within the document. How do I ensure proper sort order as well as good performance ?

I don't need the sort-order defined by sort=score desc,intField desc. The sort order needs to be somewhat like what will be delivered using product function of score*fieldVal as effective score for sort order. But I don't need exact product for sorting. Approximations are ok, & this is just to roughly define the sort order I need.

I can see a few possible ways to accomplish this:

1. Use a customized function of score for sort

2. Use query time boost to increase the score using the int field value for boost

I'm new to Solr & don't understand the performance implications of each of above case. Also, don't know if there are other better ways to accomplish what I am trying to do. So how do I build performance friendly query to achieve this sort order ?

Braiam
  • 1
  • 11
  • 47
  • 78
Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294
  • Possible duplicate of [Solr Function Query : How to use "score" field for creating custom scoring](http://stackoverflow.com/questions/36838557/solr-function-query-how-to-use-score-field-for-creating-custom-scoring) – Rangesh Ananthalwar Jan 27 '17 at 17:39

1 Answers1

2

Have a look at solr function queries

https://lucene.apache.org/solr/guide/6_6/function-queries.html#FunctionQueries-SortByFunction

Example: &sort=product(score, fieldVal)

sandrozbinden
  • 1,577
  • 1
  • 17
  • 28