You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2011/02/03 10:10:48 UTC
svn commit: r1066764 -
/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
Author: simonw
Date: Thu Feb 3 09:10:48 2011
New Revision: 1066764
URL: http://svn.apache.org/viewvc?rev=1066764&view=rev
Log:
prevent emtpy TopDocs from contributing to maxScore if searches are concurrent
Modified:
lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1066764&r1=1066763&r2=1066764&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/search/IndexSearcher.java Thu Feb 3 09:10:48 2011
@@ -373,8 +373,10 @@ public class IndexSearcher {
int totalHits = 0;
float maxScore = Float.NEGATIVE_INFINITY;
for (final TopDocs topDocs : runner) {
- totalHits += topDocs.totalHits;
- maxScore = Math.max(maxScore, topDocs.getMaxScore());
+ if(topDocs.totalHits != 0) {
+ totalHits += topDocs.totalHits;
+ maxScore = Math.max(maxScore, topDocs.getMaxScore());
+ }
}
final ScoreDoc[] scoreDocs = new ScoreDoc[hq.size()];
@@ -451,8 +453,10 @@ public class IndexSearcher {
int totalHits = 0;
float maxScore = Float.NEGATIVE_INFINITY;
for (final TopFieldDocs topFieldDocs : runner) {
- totalHits += topFieldDocs.totalHits;
- maxScore = Math.max(maxScore, topFieldDocs.getMaxScore());
+ if (topFieldDocs.totalHits != 0) {
+ totalHits += topFieldDocs.totalHits;
+ maxScore = Math.max(maxScore, topFieldDocs.getMaxScore());
+ }
}
final ScoreDoc[] scoreDocs = new ScoreDoc[hq.size()];
for (int i = hq.size() - 1; i >= 0; i--) // put docs in array