mirror of https://github.com/apache/lucene.git
LUCENE-7996: PayloadScoreQuery must produce positive scores.
This commit is contained in:
parent
63b63c5734
commit
187849f9b6
|
@ -233,11 +233,22 @@ public class PayloadScoreQuery extends SpanQuery {
|
|||
}
|
||||
|
||||
protected float getPayloadScore() {
|
||||
return function.docScore(docID(), getField(), spans.payloadsSeen, spans.payloadScore);
|
||||
float score = function.docScore(docID(), getField(), spans.payloadsSeen, spans.payloadScore);
|
||||
if (score >= 0 == false) {
|
||||
return 0;
|
||||
} else {
|
||||
return score;
|
||||
}
|
||||
}
|
||||
|
||||
protected Explanation getPayloadExplanation() {
|
||||
return function.explain(docID(), getField(), spans.payloadsSeen, spans.payloadScore);
|
||||
Explanation expl = function.explain(docID(), getField(), spans.payloadsSeen, spans.payloadScore);
|
||||
if (expl.getValue() < 0) {
|
||||
expl = Explanation.match(0, "truncated score, max of:", Explanation.match(0f, "minimum score"), expl);
|
||||
} else if (Float.isNaN(expl.getValue())) {
|
||||
expl = Explanation.match(0, "payload score, computed as (score == NaN ? 0 : score) since NaN is an illegal score from:", expl);
|
||||
}
|
||||
return expl;
|
||||
}
|
||||
|
||||
protected float getSpanScore() throws IOException {
|
||||
|
|
Loading…
Reference in New Issue