Terry Smith created LUCENE-6806: ----------------------------------- Summary: FunctionQuery.AllScorer.explain overwrites FunctionWeight.queryNorm in trappy fashion Key: LUCENE-6806 URL: https://issues.apache.org/jira/browse/LUCENE-6806 Project: Lucene - Core Issue Type: Bug Affects Versions: Trunk Reporter: Terry Smith Priority: Minor
FunctionQuery.AllScorer.explain is: {code:java} 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")); } {code} The following line has a subtle assignment that overwrites weight.queryNorm. {code:java} Explanation.match(weight.queryNorm = 1f, "queryNorm")); {code} 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? {code:java} 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")); } {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org