Index: CHANGES.txt =================================================================== --- CHANGES.txt (revision 912360) +++ CHANGES.txt (working copy) @@ -603,10 +603,10 @@ code to implement this method. If you already extend IndexSearcher, no further changes are needed to use Collector. - Finally, the values Float.NaN, Float.NEGATIVE_INFINITY and - Float.POSITIVE_INFINITY are not valid scores. Lucene uses these - values internally in certain places, so if you have hits with such - scores, it will cause problems. (Shai Erera via Mike McCandless) + Finally, the values Float.NaN and Float.NEGATIVE_INFINITY are not + valid scores. Lucene uses these values internally in certain + places, so if you have hits with such scores, it will cause + problems. (Shai Erera via Mike McCandless) * LUCENE-1687: All methods and parsers from the interface ExtendedFieldCache have been moved into FieldCache. ExtendedFieldCache is now deprecated and @@ -684,7 +684,7 @@ * LUCENE-1575: As of 2.9, the core collectors as well as IndexSearcher's search methods that return top N results, no - longer filter out zero scoring documents. If you rely on this + longer filter documents with scores <= 0.0. If you rely on this functionality you can use PositiveScoresOnlyCollector like this: Index: src/java/org/apache/lucene/search/TopScoreDocCollector.java =================================================================== --- src/java/org/apache/lucene/search/TopScoreDocCollector.java (revision 912360) +++ src/java/org/apache/lucene/search/TopScoreDocCollector.java (working copy) @@ -29,10 +29,10 @@ * instance of this collector you should know in advance whether documents are * going to be collected in doc Id order or not. * - *

NOTE: The values Float.Nan, - * Float.NEGATIVE_INFINITY and Float.POSITIVE_INFINITY are - * not valid scores. This collector will not properly - * collect hits with such scores. + *

NOTE: The values Float.Nan and + * Float.NEGATIVE_INFINITY are not valid scores. This + * collector will not properly collect hits with such + * scores. */ public abstract class TopScoreDocCollector extends TopDocsCollector { @@ -45,6 +45,11 @@ @Override public void collect(int doc) throws IOException { float score = scorer.score(); + + // This collector cannot handle these scores: + assert score != Float.NEGATIVE_INFINITY; + assert score != Float.NaN; + totalHits++; if (score <= pqTop.score) { // Since docs are returned in-order (i.e., increasing doc Id), a document @@ -72,6 +77,10 @@ @Override public void collect(int doc) throws IOException { float score = scorer.score(); + + // This collector cannot handle NaN + assert score != Float.NaN; + totalHits++; doc += docBase; if (score < pqTop.score || (score == pqTop.score && doc > pqTop.doc)) {