LUCENE-2270: fix query normalization when boosts of all clauses==0

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@911554 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2010-02-18 20:25:48 +00:00
parent 5abaff61fa
commit 44a38e9837
2 changed files with 7 additions and 0 deletions

View File

@ -81,6 +81,11 @@ Bug fixes
* LUCENE-2249: ParallelMultiSearcher should shut down thread pool on
close. (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 features

View File

@ -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;
}