diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index 2fe915e17a2..b21c6d807da 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -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 --------------------- diff --git a/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java b/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java index 543f7fac093..22dea01d6f6 100644 --- a/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java +++ b/lucene/core/src/java/org/apache/lucene/search/similarities/MultiSimilarity.java @@ -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 diff --git a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/PassageScorer.java b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/PassageScorer.java index fb43853c68e..9583553fce3 100644 --- a/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/PassageScorer.java +++ b/lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/PassageScorer.java @@ -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; } }