Apache Solr open-source search software
LUCENE-2270: fix query normalization when boosts of all clauses==0
Yonik Seeley44a38e98375c
diff --git a/CHANGES.txt b/CHANGES.txtindex 85c40590081..a7a64acd917 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -81,6 +81,11 @@ Bug fixes* LUCENE-2249: ParallelMultiSearcher should shut down thread pool onclose. (Martin Traverso via Uwe Schindler)++ * LUCENE-2770: Queries consisting of all zero-boost clauses+ (for example, text:foo^0) sorted incorrectly and produced+ invalid docids. (yonik)+New featuresdiff --git a/src/java/org/apache/lucene/search/Query.java b/src/java/org/apache/lucene/search/Query.javaindex cff67dbf5af..9250c1fa091 100644--- a/src/java/org/apache/lucene/search/Query.java+++ b/src/java/org/apache/lucene/search/Query.java@@ -101,6 +101,8 @@ public abstract class Query implements java.io.Serializable, Cloneable {Weight weight = query.createWeight(searcher);float sum = weight.sumOfSquaredWeights();float norm = getSimilarity(searcher).queryNorm(sum);+ if (Float.isInfinite(norm) || Float.isNaN(norm))+ norm = 1.0f;weight.normalize(norm);return weight;}