Search code examples
searchsolrsearch-enginerecommendation-engine

How and why do Solr 'explain' values differ from the Solr score?


While debugging the scores returned from Solr using 'debugQuery=on,' I'm seeing that the top-level values in the 'explain' section do not necessarily match up with the scores I'm seeing generated by Solr.

For example, here is the top-level debug information for the two documents:

114628: Object
  description: "sum of:"
  details: Array[2]
  match: true
  value: 20.542768

357547: Object
  description: "sum of:"
  details: Array[2]
  match: true
  value: 26.517654

But they have scores:

114628: 20.542767
357547: 13.258826

I expect the second document to be the most relevant for my query, and the debug values seem to agree. However, in the final score I receive, that document's score has been adjusted down.

Why/how does the debug value differ from the final score I see? Is there a way to get the behavior I expect?


Solution

  • This seems to be resolved after optimizing the cores in my collection.

    All of the discrepancies seemed to have their debug scores exactly halved. I'm guessing that this was due to some problem with my Solr Cloud collection having two shards replicated across two nodes.

    It could be that the scores that weren't halved were using an IDF factor calculated using only documents in one of the nodes or shards. It's still strange that the correct values appeared in the debug results and not the final score, however.

    EDIT This seemed to resolve the issue only for that one case. I occasionally see the same problem in alternate queries. Now all of the affected scores are exactly 1/4 of their debug score.

    EDIT 2 This has been identified as a bug in Lucene. Issue can be found here: https://issues.apache.org/jira/browse/LUCENE-7132

    A workaround until this is fixed is to use the BM25 Similarity in your schema.xml.

    <similarity class="solr.BM25SimilarityFactory"/>