You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by eakarsu <ea...@gmail.com> on 2014/12/12 05:51:21 UTC

Documents with SOLR function "sort" are NOT sorted by score

I am having difficulty with my sort function. With the following sort,
documents are not sorted by score if you can see. Why sort function is not
able to sort it properly?
I appreciate your prompt answer


This is my sort function.

sort=map(and(termfreq(CustomersFavourite,852708),exists($exactqq)),1,1,1,0)
desc,map(and(termfreq(CustomersPurchased,852708),exists($exactqq)),1,1,1,0)
desc,map(exists($exactqq),1,1,NumberOfClicks,0)
desc,map(exists($exactqq),1,1,Amount,0)
desc,map(and(termfreq(InPromotion_925,true),exists($exactqq)),1,1,1,0)
desc,map(exists($exactqq),1,1,OrderCount,0) desc
exactqq={!edismax}(ProductModelNameExact:xyz OR ProductModelName_TR:xyz)

But as you can results are not sorted by score

"response": {
    "numFound": 139,
    "start": 0,
    "maxScore": 0.6251737,
    "docs": [
      {
        "score": 0.28109676
      },
      {
        "score": 0.25829598
      },
      {
        "score": 0.36092186
      },
      {
        "score": 0.6251737
      },
      {
        "score": 0.1379621
      },
      {
        "score": 0.14090014
      },
      {
        "score": 0.1379621
      },
      {
        "score": 0.14090014
      },
      {
        "score": 0.50190175
      },
      {
        "score": 0.1379621
      },
      {
        "score": 0.12398934
      },
      {
        "score": 0.1379621
      },
      {
        "score": 0.12398934
      },
      {
        "score": 0.4989637
      },
      {
        "score": 0.12585841
      },
      {
        "score": 0.12585841
      },



--
View this message in context: http://lucene.472066.n3.nabble.com/Documents-with-SOLR-function-sort-are-NOT-sorted-by-score-tp4173928.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Documents with SOLR function "sort" are NOT sorted by score

Posted by Erick Erickson <er...@gmail.com>.
Searching is all about speed, and relevance calculations
can be very expensive. As Shawn says, when you explicitly
specify sort criteria you are, in effect, taking explicit control
of ranking so scores don't need to be calculated and that
expense can be avoided.

If you need score, just specify it as a secondary or
tertiary or... criteria.

Best,
Erick

On Fri, Dec 12, 2014 at 8:22 AM, Shawn Heisey <ap...@elyograg.org> wrote:
> On 12/11/2014 9:51 PM, eakarsu wrote:
>> I am having difficulty with my sort function. With the following sort,
>> documents are not sorted by score if you can see. Why sort function is not
>> able to sort it properly?
>
> I don't know why this is surprising.  If you don't use the sort
> parameter at all, the default is "score desc" ... if you DO use the sort
> parameter, that is ignored, and the sort *only* uses the parameter(s)
> you supplied.
>
> The score for each document is not affected by the sort parameter at all
> ... the only way to affect the score is to use boosting, and if you're
> doing boosting, chances are good that you're not going to use a sort
> parameter, because you'll want it sorted by score.
>
> It's my understanding that when a sort parameter is used, the score is
> ONLY calculated when you explicitly ask for it, or you turn debug on.
> If that understanding is correct, then normally there is no performance
> penalty involved for a score calculation that won't get used.
>
> Thanks,
> Shawn
>

Re: Documents with SOLR function "sort" are NOT sorted by score

Posted by Shawn Heisey <ap...@elyograg.org>.
On 12/11/2014 9:51 PM, eakarsu wrote:
> I am having difficulty with my sort function. With the following sort,
> documents are not sorted by score if you can see. Why sort function is not
> able to sort it properly?

I don't know why this is surprising.  If you don't use the sort
parameter at all, the default is "score desc" ... if you DO use the sort
parameter, that is ignored, and the sort *only* uses the parameter(s)
you supplied.

The score for each document is not affected by the sort parameter at all
... the only way to affect the score is to use boosting, and if you're
doing boosting, chances are good that you're not going to use a sort
parameter, because you'll want it sorted by score.

It's my understanding that when a sort parameter is used, the score is
ONLY calculated when you explicitly ask for it, or you turn debug on.
If that understanding is correct, then normally there is no performance
penalty involved for a score calculation that won't get used.

Thanks,
Shawn