Order solr documents with the same invoice by date added descending

I want the search results from SOLR to be ordered as follows:

All documents with the same rating will be sent in descending order by date.

Therefore, when I request solr, I will have n documents. In this result set there will be groups of documents with the same rating. I want each of these groups of documents to be ordered in descending order by date.

I found that I can accomplish this using functional queries, more precisely using the rord function http://wiki.apache.org/solr/FunctionQuery#rord , but as indicated in the documentation

WARNING: with Solr 1.4, ord () and rord () can lead to excessive memory usage since they must use the FieldCache entry from a top-level reader, while sorting and function queries now use segment-level entries. Therefore, sorting or using another function request, in addition to ord () / rord (), will double the memory usage.

this will lead to excessive memory usage.

What other parameters do I have?

I was thinking of using recip(ms(NOW,startTime),1,1,0) . Is this a better approach?

Is there a negative effect on performance if I use recipe and ms?

+7
source share
2 answers

You can use several SORT conditions:

Several sort orders can be separated by a comma, that is: sort = + [, +] ...

http://wiki.apache.org/solr/CommonQueryParameters

So in your case it will be: sort = score DESC, date_added DESC

+16
source

As your questions say:

All documents with the same rating will be sorted in descending order by date added.

The other answer you received is perfect.

In any case, I suggest you make sure that you really want to sort by date only for a document with the same account. In my experience, this has always been wrong. In fact, the solr score is not absolute, but only relative to other documents, and each document is different.

Therefore, I would not sort by invoice, and then something else, because it is difficult to predict when you will have the same invoice for different documents. I would personally sort only by score and use the function to increase the last documents. You can find a good example in the solr wiki , it uses the recip(ms(NOW,date_field),3.16e-11,1,1) function recip(ms(NOW,date_field),3.16e-11,1,1) .

If you are worried about performance, you can try increasing the speed of the index, which should be faster than increasing the query time. Take a look here .

+5
source

All Articles