epotyom commented on code in PR #15819:
URL: https://github.com/apache/lucene/pull/15819#discussion_r3347772736
##########
lucene/queries/src/java/org/apache/lucene/queries/payloads/PayloadScoreQuery.java:
##########
@@ -193,6 +195,33 @@ public ScorerSupplier scorerSupplier(LeafReaderContext
context) throws IOExcepti
}
NumericDocValues norms = context.reader().getNormValues(field);
PayloadSpans payloadSpans = new PayloadSpans(spans, decoder);
+ // When the inner weight is SpanOrWeight, use per-clause scorers so that
+ // getSpanScore() is consistent with innerWeight.explain()
+ if (innerWeight instanceof SpanOrQuery.SpanOrWeight spanOrWeight) {
Review Comment:
Ideally we don't want to leak `SpanOrQuery`/`SpanOrWeight` implementation
details into `PayloadScoreQuery`. One way to avoid it: add `public SpanScorer
createSpanScorer(Spans spans, LeafReaderContext ctx)` to `SpanWeight` with a
default implementation that creates a plain `SpanScorer`, and override it in
`SpanOrWeight` to return a scorer with per-clause scoring. `PayloadScoreQuery`
can then call `innerWeight.createSpanScorer(payloadSpans, ctx)` with no
`instanceof` check, and `SpanWeight.scorerSupplier` can delegate to it as well
to remove code duplication there. wdyt?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]