0

While tinkering solr scores in a custom BM25Similarity class using solr params, I find that the scores are logged correctly but score of docs for the same query does not change after the calculation is compiled once.

Although in the explain section of response I see the scores being calculated correctly.

    @Override
    public float score(float freq, long encodedNorm) {
      float normInverse = cache[((byte) encodedNorm) & 0xFF];
      freq = Math.min(freq, maxTf);
      return (weight - weight / (1f + freq * normInverse)) * constant;
    }

This is my score function and "constant" is something derived from a solrParam from a queryParser class. When logged, it shows extraction of constant and the score returned here is all good but in the response the score isn't reflecting.

  • Have you disabled the relevant caches inside of Solr? https://solr.apache.org/guide/solr/latest/configuration-guide/caches-warming.html – MatsLindh Mar 02 '23 at 15:11
  • But I see scores changing in the "explain" field of the response. Is it possible that explanation is recomputed everytime and results are picked up from cache? – Utkarsh Singh Mar 03 '23 at 12:33
  • Yes, that could be a reasonable explanation. – MatsLindh Mar 03 '23 at 12:43
  • 1
    I tested this hypothesis by switching off queryResultCache in solr(making size=0), and the scores are reflecting properly everytime – Utkarsh Singh Mar 05 '23 at 11:44

0 Answers0