Skip to content

Apache Lucene open-source search software

LUCENE-7486: Explain() should initialize maxScore to NEGATIVE_INFINITY too.

Adrien Grand9304ef9f118d
diff --git a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
index b29126b3444..44cbd522fc2 100644
--- a/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/DisjunctionMaxQuery.java
@@ -141,7 +141,7 @@ public final class DisjunctionMaxQuery extends Query implements Iterable<Query>
@Override
public Explanation explain(LeafReaderContext context, int doc) throws IOException {
boolean match = false;
- float max = 0.0f, sum = 0.0f;
+ float max = Float.NEGATIVE_INFINITY, sum = 0.0f;
List<Explanation> subs = new ArrayList<>();
for (Weight wt : weights) {
Explanation e = wt.explain(context, doc);