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

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 6.0
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Lucene Fields:
      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

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

                Dates

                • Created:
                  Updated: