Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-6806

FunctionQuery.AllScorer.explain overwrites FunctionWeight.queryNorm in trappy fashion

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 6.0
    • None
    • None
    • None
    • New

    Description

      FunctionQuery.AllScorer.explain is:

          public Explanation explain(int doc, float queryNorm) throws IOException {
            float sc = qWeight * vals.floatVal(doc);
      
            return Explanation.match(sc, "FunctionQuery(" + func + "), product of:",
                vals.explain(doc),
                Explanation.match(queryNorm, "boost"),
                Explanation.match(weight.queryNorm = 1f, "queryNorm"));
          }
      

      The following line has a subtle assignment that overwrites weight.queryNorm.

                Explanation.match(weight.queryNorm = 1f, "queryNorm"));
      

      Because weights aren't reused between search and explain this doesn't break anything but it's awfully subtle.

      Seeing as queryNorm is ALWAYS 1 here, could we just drop this extra line from the explain output and use the following instead?

          public Explanation explain(int doc, float queryNorm) throws IOException {
            float sc = qWeight * vals.floatVal(doc);
      
            return Explanation.match(sc, "FunctionQuery(" + func + "), product of:",
                vals.explain(doc),
                Explanation.match(queryNorm, "boost"));
          }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              shebiki Terry Smith
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: