Skip to content

Commit 6b066be

Browse files
committed
Fix bug in minmax normalizer
1 parent 346d3dd commit 6b066be

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

x-pack/plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/linear/MinMaxScoreNormalizer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public ScoreDoc[] normalizeScores(ScoreDoc[] docs) {
5656
for (int i = 0; i < docs.length; i++) {
5757
float score;
5858
if (minEqualsMax) {
59-
score = min;
59+
// This can happen if there is only one doc in the result set or if all docs have nearly equivalent scores
60+
// (i.e. within epsilon). In this case, assign every doc the max normalized score.
61+
score = 1.0f;
6062
} else {
6163
score = (docs[i].score - min) / (max - min);
6264
}

0 commit comments

Comments
 (0)