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 19:20:07 UTC

svn commit: r1066904 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/src/java/org/apache/lucene/search/IndexSearcher.java lucene/src/test/org/apache/lucene/search/TestSort.java solr/

Author: simonw
Date: Thu Feb  3 18:20:07 2011
New Revision: 1066904

URL: http://svn.apache.org/viewvc?rev=1066904&view=rev
Log:
merged rev 1066764 &  propagate settings to top-level IndexSearcher to subs if they exist

Modified:
    lucene/dev/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java
    lucene/dev/branches/branch_3x/solr/   (props changed)

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java?rev=1066904&r1=1066903&r2=1066904&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/search/IndexSearcher.java Thu Feb  3 18:20:07 2011
@@ -396,8 +396,10 @@ public class IndexSearcher extends Searc
       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()];
@@ -465,8 +467,10 @@ public class IndexSearcher extends Searc
       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
@@ -629,6 +633,11 @@ public class IndexSearcher extends Searc
   public void setDefaultFieldSortScoring(boolean doTrackScores, boolean doMaxScore) {
     fieldSortDoTrackScores = doTrackScores;
     fieldSortDoMaxScore = doMaxScore;
+    if (subSearchers != null) { // propagate settings to subs
+      for (IndexSearcher sub : subSearchers) {
+        sub.setDefaultFieldSortScoring(doTrackScores, doMaxScore);
+      }
+    }
   }
 
   /**

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java?rev=1066904&r1=1066903&r2=1066904&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestSort.java Thu Feb  3 18:20:07 2011
@@ -48,7 +48,6 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.DocIdBitSet;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util._TestUtil;
-import org.junit.Ignore;
 
 /**
  * Unit tests for sorting code.
@@ -652,7 +651,6 @@ public class TestSort extends LuceneTest
 
   // test that the relevancy scores are the same even if
   // hits are sorted
-  @Ignore("Fix me! Fails if one of the subs is a threaded indexsearcher")
   public void testNormalizedScores() throws Exception {
 
     // capture relevancy scores