Scorer should sum up scores into a double (#12682)

### Description

Addresses #12675 . Along with `MultiSimilarity.MultiSimScorer` found some others candidate scorer implementations for this fix.
This commit is contained in:
Shubham Chaudhary 2023-10-23 22:31:06 +05:30 committed by GitHub
parent 6677109ee6
commit 5461d1a160
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View File

@ -236,6 +236,8 @@ Bug Fixes
* GITHUB#12642: Ensure #finish only gets called once on the base collector during drill-sideways (Greg Miller)
* GITHUB#12682: Scorer should sum up scores into a double. (Shubham Chaudhary)
Build
---------------------

View File

@ -62,11 +62,11 @@ public class MultiSimilarity extends Similarity {
@Override
public float score(float freq, long norm) {
float sum = 0.0f;
double sum = 0d;
for (SimScorer subScorer : subScorers) {
sum += subScorer.score(freq, norm);
}
return sum;
return (float) sum;
}
@Override

View File

@ -112,7 +112,7 @@ public class PassageScorer {
}
public float score(Passage passage, int contentLength) {
float score = 0;
double score = 0d;
BytesRefHash termsHash = new BytesRefHash();
int hitCount = passage.getNumMatches();
int[] termFreqsInPassage = new int[hitCount]; // maximum size
@ -134,6 +134,6 @@ public class PassageScorer {
tf(termFreqsInPassage[i], passage.getLength()) * weight(contentLength, termFreqsInDoc[i]);
}
score *= norm(passage.getStartOffset());
return score;
return (float) score;
}
}