From 5b1a34bddd9a2bab16858d66e93f04af6500eb6b Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 21 May 2024 11:51:59 +0200 Subject: [PATCH] Fix max score computation in BlockMaxConjunctionBulkScorer. (#13397) It sums up max scores in a float when it should sum them up in a double like we do for `Scorer#score()`. Otherwise, max scores may be returned that are less than actual scores. This bug was introduced in #13343, so it is not released yet. Closes #13371 Closes #13396 --- .../apache/lucene/search/BlockMaxConjunctionBulkScorer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java index aa276d277be..9f4531540a5 100644 --- a/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java +++ b/lucene/core/src/java/org/apache/lucene/search/BlockMaxConjunctionBulkScorer.java @@ -67,7 +67,7 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer { scorers[i].advanceShallow(windowMin); } - float maxWindowScore = 0; + double maxWindowScore = 0; for (int i = 0; i < scorers.length; ++i) { float maxClauseScore = scorers[i].getMaxScore(windowMax); sumOfOtherClauses[i] = maxClauseScore; @@ -76,7 +76,7 @@ final class BlockMaxConjunctionBulkScorer extends BulkScorer { for (int i = sumOfOtherClauses.length - 2; i >= 0; --i) { sumOfOtherClauses[i] += sumOfOtherClauses[i + 1]; } - return maxWindowScore; + return (float) maxWindowScore; } @Override