lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From busc...@apache.org
Subject svn commit: r659626 [2/3] - in /lucene/java/trunk: ./ docs/ src/demo/org/apache/lucene/demo/ src/java/org/apache/lucene/document/ src/java/org/apache/lucene/search/ src/site/src/documentation/content/xdocs/ src/test/org/apache/lucene/ src/test/org/apac...
Date Fri, 23 May 2008 18:58:02 GMT
Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestLazyProxSkipping.java Fri May 23 11:57:55 2008
@@ -22,14 +22,13 @@
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.IndexInput;
 import org.apache.lucene.store.RAMDirectory;
-
 import org.apache.lucene.util.LuceneTestCase;
 
 /**
@@ -82,20 +81,20 @@
         this.searcher = new IndexSearcher(reader);        
     }
     
-    private Hits search() throws IOException {
+    private ScoreDoc[] search() throws IOException {
         // create PhraseQuery "term1 term2" and search
         PhraseQuery pq = new PhraseQuery();
         pq.add(new Term(this.field, this.term1));
         pq.add(new Term(this.field, this.term2));
-        return this.searcher.search(pq);        
+        return this.searcher.search(pq, null, 1000).scoreDocs;        
     }
     
     private void performTest(int numHits) throws IOException {
         createIndex(numHits);
         this.seeksCounter = 0;
-        Hits hits = search();
+        ScoreDoc[] hits = search();
         // verify that the right number of docs was found
-        assertEquals(numHits, hits.length());
+        assertEquals(numHits, hits.length);
         
         // check if the number of calls of seek() does not exceed the number of hits
         assertTrue(this.seeksCounter <= numHits + 1);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestParallelReader.java Fri May 23 11:57:55 2008
@@ -21,22 +21,21 @@
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.apache.lucene.util.LuceneTestCase;
-
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.MapFieldSelector;
 import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.Searcher;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.LuceneTestCase;
 
 public class TestParallelReader extends LuceneTestCase {
 
@@ -197,13 +196,13 @@
 
   
   private void queryTest(Query query) throws IOException {
-    Hits parallelHits = parallel.search(query);
-    Hits singleHits = single.search(query);
-    assertEquals(parallelHits.length(), singleHits.length());
-    for(int i = 0; i < parallelHits.length(); i++) {
-      assertEquals(parallelHits.score(i), singleHits.score(i), 0.001f);
-      Document docParallel = parallelHits.doc(i);
-      Document docSingle = singleHits.doc(i);
+    ScoreDoc[] parallelHits = parallel.search(query, null, 1000).scoreDocs;
+    ScoreDoc[] singleHits = single.search(query, null, 1000).scoreDocs;
+    assertEquals(parallelHits.length, singleHits.length);
+    for(int i = 0; i < parallelHits.length; i++) {
+      assertEquals(parallelHits[i].score, singleHits[i].score, 0.001f);
+      Document docParallel = parallel.doc(parallelHits[i].doc);
+      Document docSingle = single.doc(singleHits[i].doc);
       assertEquals(docParallel.get("f1"), docSingle.get("f1"));
       assertEquals(docParallel.get("f2"), docSingle.get("f2"));
       assertEquals(docParallel.get("f3"), docSingle.get("f3"));

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java Fri May 23 11:57:55 2008
@@ -17,7 +17,10 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.util.LuceneTestCase;
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
@@ -26,17 +29,13 @@
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
+import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
-
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.lucene.util.LuceneTestCase;
 
 /**
  * Tests QueryParser.
@@ -297,8 +296,8 @@
     mfqp.setDefaultOperator(QueryParser.Operator.AND);
     Query q = mfqp.parse("the footest");
     IndexSearcher is = new IndexSearcher(ramDir);
-    Hits hits = is.search(q);
-    assertEquals(1, hits.length());
+    ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     is.close();
   }
   

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java Fri May 23 11:57:55 2008
@@ -17,9 +17,23 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.analysis.*;
+import java.io.IOException;
+import java.io.Reader;
+import java.text.DateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Locale;
+
+import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.KeywordAnalyzer;
+import org.apache.lucene.analysis.LowerCaseTokenizer;
+import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.analysis.StopAnalyzer;
+import org.apache.lucene.analysis.StopFilter;
 import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.TokenFilter;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.DateField;
 import org.apache.lucene.document.DateTools;
@@ -27,15 +41,20 @@
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
-import org.apache.lucene.search.*;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.ConstantScoreRangeQuery;
+import org.apache.lucene.search.FuzzyQuery;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
+import org.apache.lucene.search.PhraseQuery;
+import org.apache.lucene.search.PrefixQuery;
+import org.apache.lucene.search.Query;
+import org.apache.lucene.search.RangeQuery;
+import org.apache.lucene.search.ScoreDoc;
+import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.store.RAMDirectory;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
+import org.apache.lucene.util.LuceneTestCase;
 
 /**
  * Tests QueryParser.
@@ -887,8 +906,8 @@
     QueryParser qp = new QueryParser("date", new WhitespaceAnalyzer());
     qp.setLocale(Locale.ENGLISH);
     Query q = qp.parse(query);
-    Hits hits = is.search(q);
-    assertEquals(expected, hits.length());
+    ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
+    assertEquals(expected, hits.length);
   }
 
   private static void addDateDoc(String content, int year, int month,

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/CheckHits.java Fri May 23 11:57:55 2008
@@ -123,7 +123,7 @@
       QueryUtils.check(query,(IndexSearcher)searcher);
     }
 
-    Hits hits = searcher.search(query);
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
 
     Set correct = new TreeSet();
     for (int i = 0; i < results.length; i++) {
@@ -131,8 +131,8 @@
     }
 
     Set actual = new TreeSet();
-    for (int i = 0; i < hits.length(); i++) {
-      actual.add(new Integer(hits.id(i)));
+    for (int i = 0; i < hits.length; i++) {
+      actual.add(new Integer(hits[i].doc));
     }
 
     TestCase.assertEquals(query.toString(defaultFieldName), correct, actual);
@@ -141,11 +141,11 @@
   }
 
   /** Tests that a Hits has an expected order of documents */
-  public static void checkDocIds(String mes, int[] results, Hits hits)
+  public static void checkDocIds(String mes, int[] results, ScoreDoc[] hits)
   throws IOException {
-    TestCase.assertEquals(mes + " nr of hits", results.length, hits.length());
+    TestCase.assertEquals(mes + " nr of hits", results.length, hits.length);
     for (int i = 0; i < results.length; i++) {
-      TestCase.assertEquals(mes + " doc nrs for hit " + i, results[i], hits.id(i));
+      TestCase.assertEquals(mes + " doc nrs for hit " + i, results[i], hits[i].doc);
     }
   }
 
@@ -154,8 +154,8 @@
    */
   public static void checkHitsQuery(
         Query query,
-        Hits hits1,
-        Hits hits2,
+        ScoreDoc[] hits1,
+        ScoreDoc[] hits2,
         int[] results)
           throws IOException {
 
@@ -164,33 +164,33 @@
     checkEqual(query, hits1, hits2);
   }
 
-  public static void checkEqual(Query query, Hits hits1, Hits hits2) throws IOException {
+  public static void checkEqual(Query query, ScoreDoc[] hits1, ScoreDoc[] hits2) throws IOException {
      final float scoreTolerance = 1.0e-6f;
-     if (hits1.length() != hits2.length()) {
-       TestCase.fail("Unequal lengths: hits1="+hits1.length()+",hits2="+hits2.length());
+     if (hits1.length != hits2.length) {
+       TestCase.fail("Unequal lengths: hits1="+hits1.length+",hits2="+hits2.length);
      }
-    for (int i = 0; i < hits1.length(); i++) {
-      if (hits1.id(i) != hits2.id(i)) {
+    for (int i = 0; i < hits1.length; i++) {
+      if (hits1[i].doc != hits2[i].doc) {
         TestCase.fail("Hit " + i + " docnumbers don't match\n"
                 + hits2str(hits1, hits2,0,0)
                 + "for query:" + query.toString());
       }
 
-      if ((hits1.id(i) != hits2.id(i))
-          || Math.abs(hits1.score(i) -  hits2.score(i)) > scoreTolerance)
+      if ((hits1[i].doc != hits2[i].doc)
+          || Math.abs(hits1[i].score -  hits2[i].score) > scoreTolerance)
       {
-        TestCase.fail("Hit " + i + ", doc nrs " + hits1.id(i) + " and " + hits2.id(i)
-                      + "\nunequal       : " + hits1.score(i)
-                      + "\n           and: " + hits2.score(i)
+        TestCase.fail("Hit " + i + ", doc nrs " + hits1[i].doc + " and " + hits2[i].doc
+                      + "\nunequal       : " + hits1[i].score
+                      + "\n           and: " + hits2[i].score
                       + "\nfor query:" + query.toString());
       }
     }
   }
 
-  public static String hits2str(Hits hits1, Hits hits2, int start, int end) throws IOException {
+  public static String hits2str(ScoreDoc[] hits1, ScoreDoc[] hits2, int start, int end) throws IOException {
     StringBuffer sb = new StringBuffer();
-    int len1=hits1==null ? 0 : hits1.length();
-    int len2=hits2==null ? 0 : hits2.length();
+    int len1=hits1==null ? 0 : hits1.length;
+    int len2=hits2==null ? 0 : hits2.length;
     if (end<=0) {
       end = Math.max(len1,len2);
     }
@@ -201,13 +201,13 @@
     for (int i=start; i<end; i++) {
         sb.append("hit=").append(i).append(':');
       if (i<len1) {
-          sb.append(" doc").append(hits1.id(i)).append('=').append(hits1.score(i));
+          sb.append(" doc").append(hits1[i].doc).append('=').append(hits1[i].score);
       } else {
         sb.append("               ");
       }
       sb.append(",\t");
       if (i<len2) {
-        sb.append(" doc").append(hits2.id(i)).append('=').append(hits2.score(i));
+        sb.append(" doc").append(hits2[i].doc).append('=').append(hits2[i].score);
       }
       sb.append('\n');
     }
@@ -377,19 +377,6 @@
                    new ExplanationAsserter
                    (q, null, this));
     }
-    public Hits search(Query query, Filter filter) throws IOException {
-      checkExplanations(query);
-      return super.search(query,filter);
-    }
-    public Hits search(Query query, Sort sort) throws IOException {
-      checkExplanations(query);
-      return super.search(query,sort);
-    }
-    public Hits search(Query query, Filter filter,
-                       Sort sort) throws IOException {
-      checkExplanations(query);
-      return super.search(query,filter,sort);
-    }
     public TopFieldDocs search(Query query,
                                Filter filter,
                                int n,
@@ -467,3 +454,4 @@
 
 }
 
+

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestBoolean2.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestBoolean2.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestBoolean2.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestBoolean2.java Fri May 23 11:57:55 2008
@@ -74,11 +74,11 @@
     try {
       Query query1 = makeQuery(queryText);
       BooleanQuery.setAllowDocsOutOfOrder(true);
-      Hits hits1 = searcher.search(query1);
+      ScoreDoc[] hits1 = searcher.search(query1, null, 1000).scoreDocs;
 
       Query query2 = makeQuery(queryText); // there should be no need to parse again...
       BooleanQuery.setAllowDocsOutOfOrder(false);
-      Hits hits2 = searcher.search(query2);
+      ScoreDoc[] hits2 = searcher.search(query2, null, 1000).scoreDocs;
 
       CheckHits.checkHitsQuery(query2, hits1, hits2, expDocNrs);
     } finally { // even when a test fails.
@@ -173,13 +173,11 @@
 
         QueryUtils.check(q1,searcher);
 
-        Hits hits1 = searcher.search(q1,sort);
-        if (hits1.length()>0) hits1.id(hits1.length()-1);
+        ScoreDoc[] hits1 = searcher.search(q1,null, 1000, sort).scoreDocs;
 
         BooleanQuery.setAllowDocsOutOfOrder(true);
-        Hits hits2 = searcher.search(q1,sort);
-        if (hits2.length()>0) hits2.id(hits1.length()-1);
-        tot+=hits2.length();
+        ScoreDoc[] hits2 = searcher.search(q1,null, 1000, sort).scoreDocs;
+        tot+=hits2.length;
         CheckHits.checkEqual(q1, hits1, hits2);
       }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Fri May 23 11:57:55 2008
@@ -83,11 +83,11 @@
     }
 
     public void verifyNrHits(Query q, int expected) throws Exception {
-        Hits h = s.search(q);
-        if (expected != h.length()) {
-            printHits(getName(), h);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
+        if (expected != h.length) {
+            printHits(getName(), h, s);
         }
-        assertEquals("result count", expected, h.length());
+        assertEquals("result count", expected, h.length);
         QueryUtils.check(q,s);
     }
 
@@ -375,15 +375,15 @@
 
 
 
-    protected void printHits(String test, Hits h) throws Exception {
+    protected void printHits(String test, ScoreDoc[] h, Searcher searcher) throws Exception {
 
         System.err.println("------- " + test + " -------");
 
         DecimalFormat f = new DecimalFormat("0.000000");
 
-        for (int i = 0; i < h.length(); i++) {
-            Document d = h.doc(i);
-            float score = h.score(i);
+        for (int i = 0; i < h.length; i++) {
+            Document d = searcher.doc(h[i].doc);
+            float score = h[i].score;
             System.err.println("#" + i + ": " + f.format(score) + " - " +
                                d.get("id") + " - " + d.get("data"));
         }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanOr.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanOr.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanOr.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanOr.java Fri May 23 11:57:55 2008
@@ -50,7 +50,7 @@
 
 	private int search(Query q) throws IOException {
     QueryUtils.check(q,searcher);
-    return searcher.search(q).length();
+    return searcher.search(q, null, 1000).totalHits;
 	}
 
 	public void testElements() throws IOException {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanScorer.java Fri May 23 11:57:55 2008
@@ -64,8 +64,8 @@
       query.add(new TermQuery(new Term(FIELD, "9")), BooleanClause.Occur.MUST_NOT);
 
       IndexSearcher indexSearcher = new IndexSearcher(directory);
-      Hits hits = indexSearcher.search(query);
-      assertEquals("Number of matched documents", 2, hits.length());
+      ScoreDoc[] hits = indexSearcher.search(query, null, 1000).scoreDocs;
+      assertEquals("Number of matched documents", 2, hits.length);
 
     }
     catch (IOException e) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java Fri May 23 11:57:55 2008
@@ -104,17 +104,17 @@
         IndexReader reader = IndexReader.open(small);
 	IndexSearcher search = new IndexSearcher(reader);
 
-	Hits result;
+  ScoreDoc[] result;
 
         // some hits match more terms then others, score should be the same
         
-        result = search.search(csrq("data","1","6",T,T));
-        int numHits = result.length();
+        result = search.search(csrq("data","1","6",T,T), null, 1000).scoreDocs;
+        int numHits = result.length;
         assertEquals("wrong number of results", 6, numHits);
-        float score = result.score(0);
+        float score = result[0].score;
         for (int i = 1; i < numHits; i++) {
             assertEquals("score for " + i +" was not the same",
-                         score, result.score(i));
+                         score, result[i].score);
         }
 
     }
@@ -148,10 +148,10 @@
       bq.add(q1, BooleanClause.Occur.SHOULD);
       bq.add(q2, BooleanClause.Occur.SHOULD);
 
-      Hits hits = search.search(bq);
-      assertEquals(1, hits.id(0));
-      assertEquals(0, hits.id(1));
-      assertTrue(hits.score(0) > hits.score(1));
+      ScoreDoc[] hits = search.search(bq, null, 1000).scoreDocs;
+      assertEquals(1, hits[0].doc);
+      assertEquals(0, hits[1].doc);
+      assertTrue(hits[0].score > hits[1].score);
 
       q1 = csrq("data","A","A",T,T);  // matches document #0
       q1.setBoost(10f);
@@ -160,10 +160,10 @@
       bq.add(q1, BooleanClause.Occur.SHOULD);
       bq.add(q2, BooleanClause.Occur.SHOULD);
 
-      hits = search.search(bq);
-      assertEquals(0, hits.id(0));
-      assertEquals(1, hits.id(1));
-      assertTrue(hits.score(0) > hits.score(1));
+      hits = search.search(bq, null, 1000).scoreDocs;
+      assertEquals(0, hits[0].doc);
+      assertEquals(1, hits[1].doc);
+      assertTrue(hits[0].score > hits[1].score);
     }
 
     
@@ -178,8 +178,8 @@
         
         Query rq = new RangeQuery(new Term("data","1"),new Term("data","4"),T);
 
-        Hits expected = search.search(rq);
-        int numHits = expected.length();
+        ScoreDoc[] expected = search.search(rq, null, 1000).scoreDocs;
+        int numHits = expected.length;
 
         // now do a boolean where which also contains a
         // ConstantScoreRangeQuery and make sure hte order is the same
@@ -188,12 +188,12 @@
         q.add(rq, BooleanClause.Occur.MUST);//T, F);
         q.add(csrq("data","1","6", T, T), BooleanClause.Occur.MUST);//T, F);
 
-        Hits actual = search.search(q);
+        ScoreDoc[] actual = search.search(q, null, 1000).scoreDocs;
 
-        assertEquals("wrong numebr of hits", numHits, actual.length());
+        assertEquals("wrong numebr of hits", numHits, actual.length);
         for (int i = 0; i < numHits; i++) {
             assertEquals("mismatch in docid for hit#"+i,
-                         expected.id(i), actual.id(i));
+                         expected[i].doc, actual[i].doc);
         }
 
     }
@@ -218,69 +218,69 @@
         
         assertEquals("num of docs", numDocs, 1+ maxId - minId);
         
-	Hits result;
+  ScoreDoc[] result;
 
         // test id, bounded on both ends
         
-	result = search.search(csrq("id",minIP,maxIP,T,T));
-	assertEquals("find all", numDocs, result.length());
+  result = search.search(csrq("id",minIP,maxIP,T,T), null, numDocs).scoreDocs;
+  assertEquals("find all", numDocs, result.length);
 
-	result = search.search(csrq("id",minIP,maxIP,T,F));
-	assertEquals("all but last", numDocs-1, result.length());
+  result = search.search(csrq("id",minIP,maxIP,T,F), null, numDocs).scoreDocs;
+  assertEquals("all but last", numDocs-1, result.length);
 
-	result = search.search(csrq("id",minIP,maxIP,F,T));
-	assertEquals("all but first", numDocs-1, result.length());
+  result = search.search(csrq("id",minIP,maxIP,F,T), null, numDocs).scoreDocs;
+  assertEquals("all but first", numDocs-1, result.length);
         
-	result = search.search(csrq("id",minIP,maxIP,F,F));
-        assertEquals("all but ends", numDocs-2, result.length());
+  result = search.search(csrq("id",minIP,maxIP,F,F), null, numDocs).scoreDocs;
+        assertEquals("all but ends", numDocs-2, result.length);
     
-        result = search.search(csrq("id",medIP,maxIP,T,T));
-        assertEquals("med and up", 1+ maxId-medId, result.length());
+        result = search.search(csrq("id",medIP,maxIP,T,T), null, numDocs).scoreDocs;
+        assertEquals("med and up", 1+ maxId-medId, result.length);
         
-        result = search.search(csrq("id",minIP,medIP,T,T));
-        assertEquals("up to med", 1+ medId-minId, result.length());
+        result = search.search(csrq("id",minIP,medIP,T,T), null, numDocs).scoreDocs;
+        assertEquals("up to med", 1+ medId-minId, result.length);
 
         // unbounded id
 
-	result = search.search(csrq("id",minIP,null,T,F));
-	assertEquals("min and up", numDocs, result.length());
+  result = search.search(csrq("id",minIP,null,T,F), null, numDocs).scoreDocs;
+  assertEquals("min and up", numDocs, result.length);
 
-	result = search.search(csrq("id",null,maxIP,F,T));
-	assertEquals("max and down", numDocs, result.length());
+  result = search.search(csrq("id",null,maxIP,F,T), null, numDocs).scoreDocs;
+  assertEquals("max and down", numDocs, result.length);
 
-	result = search.search(csrq("id",minIP,null,F,F));
-	assertEquals("not min, but up", numDocs-1, result.length());
+  result = search.search(csrq("id",minIP,null,F,F), null, numDocs).scoreDocs;
+  assertEquals("not min, but up", numDocs-1, result.length);
         
-	result = search.search(csrq("id",null,maxIP,F,F));
-	assertEquals("not max, but down", numDocs-1, result.length());
+  result = search.search(csrq("id",null,maxIP,F,F), null, numDocs).scoreDocs;
+  assertEquals("not max, but down", numDocs-1, result.length);
         
-        result = search.search(csrq("id",medIP,maxIP,T,F));
-        assertEquals("med and up, not max", maxId-medId, result.length());
+        result = search.search(csrq("id",medIP,maxIP,T,F), null, numDocs).scoreDocs;
+        assertEquals("med and up, not max", maxId-medId, result.length);
         
-        result = search.search(csrq("id",minIP,medIP,F,T));
-        assertEquals("not min, up to med", medId-minId, result.length());
+        result = search.search(csrq("id",minIP,medIP,F,T), null, numDocs).scoreDocs;
+        assertEquals("not min, up to med", medId-minId, result.length);
 
         // very small sets
 
-	result = search.search(csrq("id",minIP,minIP,F,F));
-	assertEquals("min,min,F,F", 0, result.length());
-	result = search.search(csrq("id",medIP,medIP,F,F));
-	assertEquals("med,med,F,F", 0, result.length());
-	result = search.search(csrq("id",maxIP,maxIP,F,F));
-	assertEquals("max,max,F,F", 0, result.length());
+  result = search.search(csrq("id",minIP,minIP,F,F), null, numDocs).scoreDocs;
+  assertEquals("min,min,F,F", 0, result.length);
+  result = search.search(csrq("id",medIP,medIP,F,F), null, numDocs).scoreDocs;
+  assertEquals("med,med,F,F", 0, result.length);
+  result = search.search(csrq("id",maxIP,maxIP,F,F), null, numDocs).scoreDocs;
+  assertEquals("max,max,F,F", 0, result.length);
                      
-	result = search.search(csrq("id",minIP,minIP,T,T));
-	assertEquals("min,min,T,T", 1, result.length());
-	result = search.search(csrq("id",null,minIP,F,T));
-	assertEquals("nul,min,F,T", 1, result.length());
-
-	result = search.search(csrq("id",maxIP,maxIP,T,T));
-	assertEquals("max,max,T,T", 1, result.length());
-	result = search.search(csrq("id",maxIP,null,T,F));
-	assertEquals("max,nul,T,T", 1, result.length());
+  result = search.search(csrq("id",minIP,minIP,T,T), null, numDocs).scoreDocs;
+  assertEquals("min,min,T,T", 1, result.length);
+  result = search.search(csrq("id",null,minIP,F,T), null, numDocs).scoreDocs;
+  assertEquals("nul,min,F,T", 1, result.length);
+
+  result = search.search(csrq("id",maxIP,maxIP,T,T), null, numDocs).scoreDocs;
+  assertEquals("max,max,T,T", 1, result.length);
+  result = search.search(csrq("id",maxIP,null,T,F), null, numDocs).scoreDocs;
+  assertEquals("max,nul,T,T", 1, result.length);
 
-	result = search.search(csrq("id",medIP,medIP,T,T));
-	assertEquals("med,med,T,T", 1, result.length());
+  result = search.search(csrq("id",medIP,medIP,T,T), null, numDocs).scoreDocs;
+  assertEquals("med,med,T,T", 1, result.length);
         
     }
 
@@ -297,53 +297,53 @@
         
         assertEquals("num of docs", numDocs, 1+ maxId - minId);
         
-	Hits result;
+  ScoreDoc[] result;
         Query q = new TermQuery(new Term("body","body"));
 
         // test extremes, bounded on both ends
         
-	result = search.search(csrq("rand",minRP,maxRP,T,T));
-	assertEquals("find all", numDocs, result.length());
+  result = search.search(csrq("rand",minRP,maxRP,T,T), null, numDocs).scoreDocs;
+  assertEquals("find all", numDocs, result.length);
 
-	result = search.search(csrq("rand",minRP,maxRP,T,F));
-	assertEquals("all but biggest", numDocs-1, result.length());
+  result = search.search(csrq("rand",minRP,maxRP,T,F), null, numDocs).scoreDocs;
+  assertEquals("all but biggest", numDocs-1, result.length);
 
-	result = search.search(csrq("rand",minRP,maxRP,F,T));
-	assertEquals("all but smallest", numDocs-1, result.length());
+  result = search.search(csrq("rand",minRP,maxRP,F,T), null, numDocs).scoreDocs;
+  assertEquals("all but smallest", numDocs-1, result.length);
         
-	result = search.search(csrq("rand",minRP,maxRP,F,F));
-        assertEquals("all but extremes", numDocs-2, result.length());
+  result = search.search(csrq("rand",minRP,maxRP,F,F), null, numDocs).scoreDocs;
+        assertEquals("all but extremes", numDocs-2, result.length);
     
         // unbounded
 
-	result = search.search(csrq("rand",minRP,null,T,F));
-	assertEquals("smallest and up", numDocs, result.length());
+  result = search.search(csrq("rand",minRP,null,T,F), null, numDocs).scoreDocs;
+  assertEquals("smallest and up", numDocs, result.length);
 
-	result = search.search(csrq("rand",null,maxRP,F,T));
-	assertEquals("biggest and down", numDocs, result.length());
+  result = search.search(csrq("rand",null,maxRP,F,T), null, numDocs).scoreDocs;
+  assertEquals("biggest and down", numDocs, result.length);
 
-	result = search.search(csrq("rand",minRP,null,F,F));
-	assertEquals("not smallest, but up", numDocs-1, result.length());
+  result = search.search(csrq("rand",minRP,null,F,F), null, numDocs).scoreDocs;
+  assertEquals("not smallest, but up", numDocs-1, result.length);
         
-	result = search.search(csrq("rand",null,maxRP,F,F));
-	assertEquals("not biggest, but down", numDocs-1, result.length());
+  result = search.search(csrq("rand",null,maxRP,F,F), null, numDocs).scoreDocs;
+  assertEquals("not biggest, but down", numDocs-1, result.length);
         
         // very small sets
 
-	result = search.search(csrq("rand",minRP,minRP,F,F));
-	assertEquals("min,min,F,F", 0, result.length());
-	result = search.search(csrq("rand",maxRP,maxRP,F,F));
-	assertEquals("max,max,F,F", 0, result.length());
+  result = search.search(csrq("rand",minRP,minRP,F,F), null, numDocs).scoreDocs;
+  assertEquals("min,min,F,F", 0, result.length);
+  result = search.search(csrq("rand",maxRP,maxRP,F,F), null, numDocs).scoreDocs;
+  assertEquals("max,max,F,F", 0, result.length);
                      
-	result = search.search(csrq("rand",minRP,minRP,T,T));
-	assertEquals("min,min,T,T", 1, result.length());
-	result = search.search(csrq("rand",null,minRP,F,T));
-	assertEquals("nul,min,F,T", 1, result.length());
-
-	result = search.search(csrq("rand",maxRP,maxRP,T,T));
-	assertEquals("max,max,T,T", 1, result.length());
-	result = search.search(csrq("rand",maxRP,null,T,F));
-	assertEquals("max,nul,T,T", 1, result.length());
+  result = search.search(csrq("rand",minRP,minRP,T,T), null, numDocs).scoreDocs;
+  assertEquals("min,min,T,T", 1, result.length);
+  result = search.search(csrq("rand",null,minRP,F,T), null, numDocs).scoreDocs;
+  assertEquals("nul,min,F,T", 1, result.length);
+
+  result = search.search(csrq("rand",maxRP,maxRP,T,T), null, numDocs).scoreDocs;
+  assertEquals("max,max,T,T", 1, result.length);
+  result = search.search(csrq("rand",maxRP,null,T,F), null, numDocs).scoreDocs;
+  assertEquals("max,nul,T,T", 1, result.length);
         
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Fri May 23 11:57:55 2008
@@ -151,24 +151,24 @@
 	private void matchHits (Searcher searcher, Sort sort)
 	throws IOException {
 	    // make a query without sorting first
-		Hits hitsByRank = searcher.search(query);
+    ScoreDoc[] hitsByRank = searcher.search(query, null, 1000).scoreDocs;
 		checkHits(hitsByRank, "Sort by rank: "); // check for duplicates
         Map resultMap = new TreeMap();
         // store hits in TreeMap - TreeMap does not allow duplicates; existing entries are silently overwritten
-        for(int hitid=0;hitid<hitsByRank.length(); ++hitid) {
+        for(int hitid=0;hitid<hitsByRank.length; ++hitid) {
             resultMap.put(
-                    new Integer(hitsByRank.id(hitid)),  // Key:   Lucene Document ID
+                    new Integer(hitsByRank[hitid].doc),  // Key:   Lucene Document ID
                     new Integer(hitid));				// Value: Hits-Objekt Index
         }
         
         // now make a query using the sort criteria
-		Hits resultSort = searcher.search (query, sort);
+    ScoreDoc[] resultSort = searcher.search (query, null, 1000, sort).scoreDocs;
 		checkHits(resultSort, "Sort by custom criteria: "); // check for duplicates
 		
         String lf = System.getProperty("line.separator", "\n");
         // besides the sorting both sets of hits must be identical
-        for(int hitid=0;hitid<resultSort.length(); ++hitid) {
-            Integer idHitDate = new Integer(resultSort.id(hitid)); // document ID from sorted search
+        for(int hitid=0;hitid<resultSort.length; ++hitid) {
+            Integer idHitDate = new Integer(resultSort[hitid].doc); // document ID from sorted search
             if(!resultMap.containsKey(idHitDate)) {
                 log("ID "+idHitDate+" not found. Possibliy a duplicate.");
             }
@@ -189,33 +189,24 @@
 	 * Check the hits for duplicates.
 	 * @param hits
 	 */
-    private void checkHits(Hits hits, String prefix) {
+    private void checkHits(ScoreDoc[] hits, String prefix) {
         if(hits!=null) {
             Map idMap = new TreeMap();
-            for(int docnum=0;docnum<hits.length();++docnum) {
+            for(int docnum=0;docnum<hits.length;++docnum) {
                 Integer luceneId = null;
-                try {
-                    luceneId = new Integer(hits.id(docnum));
-                    if(idMap.containsKey(luceneId)) {
-                        StringBuffer message = new StringBuffer(prefix);
-                        message.append("Duplicate key for hit index = ");
-                        message.append(docnum);
-                        message.append(", previous index = ");
-                        message.append(((Integer)idMap.get(luceneId)).toString());
-                        message.append(", Lucene ID = ");
-                        message.append(luceneId);
-                        log(message.toString());
-                    } else { 
-                        idMap.put(luceneId, new Integer(docnum));
-                    }
-                } catch(IOException ioe) {
+
+                luceneId = new Integer(hits[docnum].doc);
+                if(idMap.containsKey(luceneId)) {
                     StringBuffer message = new StringBuffer(prefix);
-                    message.append("Error occurred for hit index = ");
+                    message.append("Duplicate key for hit index = ");
                     message.append(docnum);
-                    message.append(" (");
-                    message.append(ioe.getMessage());
-                    message.append(")");
+                    message.append(", previous index = ");
+                    message.append(((Integer)idMap.get(luceneId)).toString());
+                    message.append(", Lucene ID = ");
+                    message.append(luceneId);
                     log(message.toString());
+                } else { 
+                    idMap.put(luceneId, new Integer(docnum));
                 }
             }
         }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java Fri May 23 11:57:55 2008
@@ -79,28 +79,28 @@
 	// search for something that does exists
 	Query query2 = new TermQuery(new Term("body", "sunny"));
 
-	Hits result;
+  ScoreDoc[] result;
 
 	// ensure that queries return expected results without DateFilter first
-	result = searcher.search(query1);
-	assertEquals(0, result.length());
+  result = searcher.search(query1, null, 1000).scoreDocs;
+  assertEquals(0, result.length);
 
-	result = searcher.search(query2);
-	assertEquals(1, result.length());
+  result = searcher.search(query2, null, 1000).scoreDocs;
+  assertEquals(1, result.length);
 
 
 	// run queries with DateFilter
-	result = searcher.search(query1, df1);
-	assertEquals(0, result.length());
+  result = searcher.search(query1, df1, 1000).scoreDocs;
+  assertEquals(0, result.length);
 
-	result = searcher.search(query1, df2);
-	assertEquals(0, result.length());
+  result = searcher.search(query1, df2, 1000).scoreDocs;
+  assertEquals(0, result.length);
 
- 	result = searcher.search(query2, df1);
- 	assertEquals(1, result.length());
+   result = searcher.search(query2, df1, 1000).scoreDocs;
+   assertEquals(1, result.length);
 
-	result = searcher.search(query2, df2);
-	assertEquals(0, result.length());
+  result = searcher.search(query2, df2, 1000).scoreDocs;
+  assertEquals(0, result.length);
     }
 
     /**
@@ -140,27 +140,27 @@
 	// search for something that does exists
 	Query query2 = new TermQuery(new Term("body", "sunny"));
 
-	Hits result;
+  ScoreDoc[] result;
 
 	// ensure that queries return expected results without DateFilter first
-	result = searcher.search(query1);
-	assertEquals(0, result.length());
+  result = searcher.search(query1, null, 1000).scoreDocs;
+  assertEquals(0, result.length);
 
-	result = searcher.search(query2);
-	assertEquals(1, result.length());
+  result = searcher.search(query2, null, 1000).scoreDocs;
+  assertEquals(1, result.length);
 
 
 	// run queries with DateFilter
-	result = searcher.search(query1, df1);
-	assertEquals(0, result.length());
+  result = searcher.search(query1, df1, 1000).scoreDocs;
+  assertEquals(0, result.length);
 
-	result = searcher.search(query1, df2);
-	assertEquals(0, result.length());
+  result = searcher.search(query1, df2, 1000).scoreDocs;
+  assertEquals(0, result.length);
 
- 	result = searcher.search(query2, df1);
- 	assertEquals(1, result.length());
+   result = searcher.search(query2, df1, 1000).scoreDocs;
+   assertEquals(1, result.length);
 
-	result = searcher.search(query2, df2);
-	assertEquals(0, result.length());
+  result = searcher.search(query2, df2, 1000).scoreDocs;
+  assertEquals(0, result.length);
     }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java Fri May 23 11:57:55 2008
@@ -27,7 +27,6 @@
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Sort;
@@ -81,9 +80,9 @@
 
     // Execute the search and process the search results.
     String[] actualOrder = new String[5];
-    Hits hits = searcher.search(query, sort);
-    for (int i = 0; i < hits.length(); i++) {
-      Document document = hits.doc(i);
+    ScoreDoc[] hits = searcher.search(query, null, 1000, sort).scoreDocs;
+    for (int i = 0; i < hits.length; i++) {
+      Document document = searcher.doc(hits[i].doc);
       String text = document.get(TEXT_FIELD);
       actualOrder[i] = text;
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java Fri May 23 11:57:55 2008
@@ -166,19 +166,19 @@
         q.add(tq("hed","elephant"));
         QueryUtils.check(q,s);
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
             assertEquals("all docs should match " + q.toString(),
-                         4, h.length());
+                         4, h.length);
 
-            float score = h.score(0);
-            for (int i = 1; i < h.length(); i++) {
+            float score = h[0].score;
+            for (int i = 1; i < h.length; i++) {
                 assertEquals("score #" + i + " is not the same",
-                             score, h.score(i), SCORE_COMP_THRESH);
+                             score, h[i].score, SCORE_COMP_THRESH);
             }
         } catch (Error e) {
-            printHits("testSimpleEqualScores1",h);
+            printHits("testSimpleEqualScores1",h,s);
             throw e;
         }
 
@@ -193,18 +193,18 @@
         QueryUtils.check(q,s);
 
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
             assertEquals("3 docs should match " + q.toString(),
-                         3, h.length());
-            float score = h.score(0);
-            for (int i = 1; i < h.length(); i++) {
+                         3, h.length);
+            float score = h[0].score;
+            for (int i = 1; i < h.length; i++) {
                 assertEquals("score #" + i + " is not the same",
-                             score, h.score(i), SCORE_COMP_THRESH);
+                             score, h[i].score, SCORE_COMP_THRESH);
             }
         } catch (Error e) {
-            printHits("testSimpleEqualScores2",h);
+            printHits("testSimpleEqualScores2",h, s);
             throw e;
         }
 
@@ -220,18 +220,18 @@
         QueryUtils.check(q,s);
 
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
             assertEquals("all docs should match " + q.toString(),
-                         4, h.length());
-            float score = h.score(0);
-            for (int i = 1; i < h.length(); i++) {
+                         4, h.length);
+            float score = h[0].score;
+            for (int i = 1; i < h.length; i++) {
                 assertEquals("score #" + i + " is not the same",
-                             score, h.score(i), SCORE_COMP_THRESH);
+                             score, h[i].score, SCORE_COMP_THRESH);
             }
         } catch (Error e) {
-            printHits("testSimpleEqualScores3",h);
+            printHits("testSimpleEqualScores3",h, s);
             throw e;
         }
 
@@ -245,22 +245,22 @@
         QueryUtils.check(q,s);
 
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
             assertEquals("3 docs should match " + q.toString(),
-                         3, h.length());
-            assertEquals("wrong first",  "d2", h.doc(0).get("id"));
-            float score0 = h.score(0);
-            float score1 = h.score(1);
-            float score2 = h.score(2);
+                         3, h.length);
+            assertEquals("wrong first",  "d2", s.doc(h[0].doc).get("id"));
+            float score0 = h[0].score;
+            float score1 = h[1].score;
+            float score2 = h[2].score;
             assertTrue("d2 does not have better score then others: " +
                        score0 + " >? " + score1,
                        score0 > score1);
             assertEquals("d4 and d1 don't have equal scores",
                          score1, score2, SCORE_COMP_THRESH);
         } catch (Error e) {
-            printHits("testSimpleTiebreaker",h);
+            printHits("testSimpleTiebreaker",h, s);
             throw e;
         }
     }
@@ -286,18 +286,18 @@
 
         QueryUtils.check(q,s);
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
             assertEquals("3 docs should match " + q.toString(),
-                         3, h.length());
-            float score = h.score(0);
-            for (int i = 1; i < h.length(); i++) {
+                         3, h.length);
+            float score = h[0].score;
+            for (int i = 1; i < h.length; i++) {
                 assertEquals("score #" + i + " is not the same",
-                             score, h.score(i), SCORE_COMP_THRESH);
+                             score, h[i].score, SCORE_COMP_THRESH);
             }
         } catch (Error e) {
-            printHits("testBooleanRequiredEqualScores1",h);
+            printHits("testBooleanRequiredEqualScores1",h, s);
             throw e;
         }
     }
@@ -321,23 +321,23 @@
         QueryUtils.check(q,s);
 
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
             assertEquals("4 docs should match " + q.toString(),
-                         4, h.length());
-            float score = h.score(0);
-            for (int i = 1; i < h.length()-1; i++) { /* note: -1 */
+                         4, h.length);
+            float score = h[0].score;
+            for (int i = 1; i < h.length-1; i++) { /* note: -1 */
                 assertEquals("score #" + i + " is not the same",
-                             score, h.score(i), SCORE_COMP_THRESH);
+                             score, h[i].score, SCORE_COMP_THRESH);
             }
-            assertEquals("wrong last", "d1", h.doc(h.length()-1).get("id"));
-            float score1 = h.score(h.length()-1);
+            assertEquals("wrong last", "d1", s.doc(h[h.length-1].doc).get("id"));
+            float score1 = h[h.length-1].score;
             assertTrue("d1 does not have worse score then others: " +
                        score + " >? " + score1,
                        score > score1);
         } catch (Error e) {
-            printHits("testBooleanOptionalNoTiebreaker",h);
+            printHits("testBooleanOptionalNoTiebreaker",h, s);
             throw e;
         }
     }
@@ -361,22 +361,22 @@
         QueryUtils.check(q,s);
 
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
 
             assertEquals("4 docs should match " + q.toString(),
-                         4, h.length());
+                         4, h.length);
 
-            float score0 = h.score(0);
-            float score1 = h.score(1);
-            float score2 = h.score(2);
-            float score3 = h.score(3);
-
-            String doc0 = h.doc(0).get("id");
-            String doc1 = h.doc(1).get("id");
-            String doc2 = h.doc(2).get("id");
-            String doc3 = h.doc(3).get("id");
+            float score0 = h[0].score;
+            float score1 = h[1].score;
+            float score2 = h[2].score;
+            float score3 = h[3].score;
+
+            String doc0 = s.doc(h[0].doc).get("id");
+            String doc1 = s.doc(h[1].doc).get("id");
+            String doc2 = s.doc(h[2].doc).get("id");
+            String doc3 = s.doc(h[3].doc).get("id");            
 
             assertTrue("doc0 should be d2 or d4: " + doc0,
                        doc0.equals("d2") || doc0.equals("d4"));
@@ -395,7 +395,7 @@
                        score2 > score3);
 
         } catch (Error e) {
-            printHits("testBooleanOptionalWithTiebreaker",h);
+            printHits("testBooleanOptionalWithTiebreaker",h, s);
             throw e;
         }
 
@@ -420,22 +420,22 @@
         QueryUtils.check(q,s);
 
 
-        Hits h = s.search(q);
+        ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
 
         try {
 
             assertEquals("4 docs should match " + q.toString(),
-                         4, h.length());
+                         4, h.length);
 
-            float score0 = h.score(0);
-            float score1 = h.score(1);
-            float score2 = h.score(2);
-            float score3 = h.score(3);
-
-            String doc0 = h.doc(0).get("id");
-            String doc1 = h.doc(1).get("id");
-            String doc2 = h.doc(2).get("id");
-            String doc3 = h.doc(3).get("id");
+            float score0 = h[0].score;
+            float score1 = h[1].score;
+            float score2 = h[2].score;
+            float score3 = h[3].score;
+
+            String doc0 = s.doc(h[0].doc).get("id");
+            String doc1 = s.doc(h[1].doc).get("id");
+            String doc2 = s.doc(h[2].doc).get("id");
+            String doc3 = s.doc(h[3].doc).get("id");            
 
             assertEquals("doc0 should be d4: ", "d4", doc0);
             assertEquals("doc1 should be d3: ", "d3", doc1);
@@ -453,7 +453,7 @@
                        score2 > score3);
 
         } catch (Error e) {
-            printHits("testBooleanOptionalWithTiebreakerAndBoost",h);
+            printHits("testBooleanOptionalWithTiebreakerAndBoost",h, s);
             throw e;
         }
     }
@@ -476,15 +476,15 @@
     }
 
 
-    protected void printHits(String test, Hits h) throws Exception {
+    protected void printHits(String test, ScoreDoc[] h, Searcher searcher) throws Exception {
 
         System.err.println("------- " + test + " -------");
 
         DecimalFormat f = new DecimalFormat("0.000000000");
 
-        for (int i = 0; i < h.length(); i++) {
-            Document d = h.doc(i);
-            float score = h.score(i);
+        for (int i = 0; i < h.length; i++) {
+            Document d = searcher.doc(h[i].doc);
+            float score = h[i].score;
             System.err.println("#" + i + ": " + f.format(score) + " - " +
                                d.get("id"));
         }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java Fri May 23 11:57:55 2008
@@ -101,29 +101,29 @@
   public void testFilteredQuery()
   throws Exception {
     Query filteredquery = new FilteredQuery (query, filter);
-    Hits hits = searcher.search (filteredquery);
-    assertEquals (1, hits.length());
-    assertEquals (1, hits.id(0));
+    ScoreDoc[] hits = searcher.search (filteredquery, null, 1000).scoreDocs;
+    assertEquals (1, hits.length);
+    assertEquals (1, hits[0].doc);
     QueryUtils.check(filteredquery,searcher);
 
-    hits = searcher.search (filteredquery, new Sort("sorter"));
-    assertEquals (1, hits.length());
-    assertEquals (1, hits.id(0));
+    hits = searcher.search (filteredquery, null, 1000, new Sort("sorter")).scoreDocs;
+    assertEquals (1, hits.length);
+    assertEquals (1, hits[0].doc);
 
     filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "one")), filter);
-    hits = searcher.search (filteredquery);
-    assertEquals (2, hits.length());
+    hits = searcher.search (filteredquery, null, 1000).scoreDocs;
+    assertEquals (2, hits.length);
     QueryUtils.check(filteredquery,searcher);
 
     filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "x")), filter);
-    hits = searcher.search (filteredquery);
-    assertEquals (1, hits.length());
-    assertEquals (3, hits.id(0));
+    hits = searcher.search (filteredquery, null, 1000).scoreDocs;
+    assertEquals (1, hits.length);
+    assertEquals (3, hits[0].doc);
     QueryUtils.check(filteredquery,searcher);
 
     filteredquery = new FilteredQuery (new TermQuery (new Term ("field", "y")), filter);
-    hits = searcher.search (filteredquery);
-    assertEquals (0, hits.length());
+    hits = searcher.search (filteredquery, null, 1000).scoreDocs;
+    assertEquals (0, hits.length);
     QueryUtils.check(filteredquery,searcher);
     
     // test boost
@@ -163,13 +163,13 @@
    * Tests whether the scores of the two queries are the same.
    */
   public void assertScoreEquals(Query q1, Query q2) throws Exception {
-    Hits hits1 = searcher.search (q1);
-    Hits hits2 = searcher.search (q2);
+    ScoreDoc[] hits1 = searcher.search (q1, null, 1000).scoreDocs;
+    ScoreDoc[] hits2 = searcher.search (q2, null, 1000).scoreDocs;
       
-    assertEquals(hits1.length(), hits2.length());
+    assertEquals(hits1.length, hits2.length);
     
-    for (int i = 0; i < hits1.length(); i++) {
-      assertEquals(hits1.score(i), hits2.score(i), 0.0000001f);
+    for (int i = 0; i < hits1.length; i++) {
+      assertEquals(hits1[i].score, hits2[i].score, 0.0000001f);
     }
   }
 
@@ -181,8 +181,8 @@
         new Term("sorter", "b"), new Term("sorter", "d"), true);
 
     Query filteredquery = new FilteredQuery(rq, filter);
-    Hits hits = searcher.search(filteredquery);
-    assertEquals(2, hits.length());
+    ScoreDoc[] hits = searcher.search(filteredquery, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
     QueryUtils.check(filteredquery,searcher);
   }
 
@@ -194,11 +194,12 @@
     query = new FilteredQuery(new MatchAllDocsQuery(),
         new SingleDocTestFilter(1));
     bq.add(query, BooleanClause.Occur.MUST);
-    Hits hits = searcher.search(bq);
-    assertEquals(0, hits.length());
+    ScoreDoc[] hits = searcher.search(bq, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     QueryUtils.check(query,searcher);    
   }
 }
 
 
 
+

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredSearch.java Fri May 23 11:57:55 2008
@@ -63,8 +63,8 @@
      
      
       IndexSearcher indexSearcher = new IndexSearcher(directory);
-      org.apache.lucene.search.Hits hits = indexSearcher.search(booleanQuery, filter);
-      assertEquals("Number of matched documents", 1, hits.length());
+      ScoreDoc[] hits = indexSearcher.search(booleanQuery, filter, 1000).scoreDocs;
+      assertEquals("Number of matched documents", 1, hits.length);
 
     }
     catch (IOException e) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFuzzyQuery.java Fri May 23 11:57:55 2008
@@ -49,114 +49,114 @@
     IndexSearcher searcher = new IndexSearcher(directory);
 
     FuzzyQuery query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 0);   
-    Hits hits = searcher.search(query);
-    assertEquals(3, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
     
     // same with prefix
     query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 1);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
     query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 2);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
     query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 3);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
     query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 4);   
-    hits = searcher.search(query);
-    assertEquals(2, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
     query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 5);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 6);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     // not similar enough:
     query = new FuzzyQuery(new Term("field", "xxxxx"), FuzzyQuery.defaultMinSimilarity, 0);  	
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     query = new FuzzyQuery(new Term("field", "aaccc"), FuzzyQuery.defaultMinSimilarity, 0);   // edit distance to "aaaaa" = 3
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // query identical to a word in the index:
     query = new FuzzyQuery(new Term("field", "aaaaa"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaa"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaa"));
     // default allows for up to two edits:
-    assertEquals(hits.doc(1).get("field"), ("aaaab"));
-    assertEquals(hits.doc(2).get("field"), ("aaabb"));
+    assertEquals(searcher.doc(hits[1].doc).get("field"), ("aaaab"));
+    assertEquals(searcher.doc(hits[2].doc).get("field"), ("aaabb"));
 
     // query similar to a word in the index:
     query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaa"));
-    assertEquals(hits.doc(1).get("field"), ("aaaab"));
-    assertEquals(hits.doc(2).get("field"), ("aaabb"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaa"));
+    assertEquals(searcher.doc(hits[1].doc).get("field"), ("aaaab"));
+    assertEquals(searcher.doc(hits[2].doc).get("field"), ("aaabb"));
     
     // now with prefix
     query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 1);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaa"));
-    assertEquals(hits.doc(1).get("field"), ("aaaab"));
-    assertEquals(hits.doc(2).get("field"), ("aaabb"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaa"));
+    assertEquals(searcher.doc(hits[1].doc).get("field"), ("aaaab"));
+    assertEquals(searcher.doc(hits[2].doc).get("field"), ("aaabb"));
     query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 2);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaa"));
-    assertEquals(hits.doc(1).get("field"), ("aaaab"));
-    assertEquals(hits.doc(2).get("field"), ("aaabb"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaa"));
+    assertEquals(searcher.doc(hits[1].doc).get("field"), ("aaaab"));
+    assertEquals(searcher.doc(hits[2].doc).get("field"), ("aaabb"));
     query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 3);   
-    hits = searcher.search(query);
-    assertEquals(3, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaa"));
-    assertEquals(hits.doc(1).get("field"), ("aaaab"));
-    assertEquals(hits.doc(2).get("field"), ("aaabb"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaa"));
+    assertEquals(searcher.doc(hits[1].doc).get("field"), ("aaaab"));
+    assertEquals(searcher.doc(hits[2].doc).get("field"), ("aaabb"));
     query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 4);   
-    hits = searcher.search(query);
-    assertEquals(2, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaa"));
-    assertEquals(hits.doc(1).get("field"), ("aaaab"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaa"));
+    assertEquals(searcher.doc(hits[1].doc).get("field"), ("aaaab"));
     query = new FuzzyQuery(new Term("field", "aaaac"), FuzzyQuery.defaultMinSimilarity, 5);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     
 
     query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("ddddd"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("ddddd"));
     
     // now with prefix
     query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 1);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("ddddd"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("ddddd"));
     query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 2);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("ddddd"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("ddddd"));
     query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 3);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("ddddd"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("ddddd"));
     query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 4);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("ddddd"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("ddddd"));
     query = new FuzzyQuery(new Term("field", "ddddX"), FuzzyQuery.defaultMinSimilarity, 5);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     
 
     // different field = no match:
     query = new FuzzyQuery(new Term("anotherfield", "ddddX"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     searcher.close();
     directory.close();
@@ -174,64 +174,64 @@
     FuzzyQuery query;
     // not similar enough:
     query = new FuzzyQuery(new Term("field", "xxxxx"), FuzzyQuery.defaultMinSimilarity, 0);   
-    Hits hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     // edit distance to "aaaaaaa" = 3, this matches because the string is longer than
     // in testDefaultFuzziness so a bigger difference is allowed:
     query = new FuzzyQuery(new Term("field", "aaaaccc"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaaaa"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaaaa"));
     
     // now with prefix
     query = new FuzzyQuery(new Term("field", "aaaaccc"), FuzzyQuery.defaultMinSimilarity, 1);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaaaa"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaaaa"));
     query = new FuzzyQuery(new Term("field", "aaaaccc"), FuzzyQuery.defaultMinSimilarity, 4);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
-    assertEquals(hits.doc(0).get("field"), ("aaaaaaa"));
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    assertEquals(searcher.doc(hits[0].doc).get("field"), ("aaaaaaa"));
     query = new FuzzyQuery(new Term("field", "aaaaccc"), FuzzyQuery.defaultMinSimilarity, 5);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // no match, more than half of the characters is wrong:
     query = new FuzzyQuery(new Term("field", "aaacccc"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     
     // now with prefix
     query = new FuzzyQuery(new Term("field", "aaacccc"), FuzzyQuery.defaultMinSimilarity, 2);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // "student" and "stellent" are indeed similar to "segment" by default:
     query = new FuzzyQuery(new Term("field", "student"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     query = new FuzzyQuery(new Term("field", "stellent"), FuzzyQuery.defaultMinSimilarity, 0);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     
     // now with prefix
     query = new FuzzyQuery(new Term("field", "student"), FuzzyQuery.defaultMinSimilarity, 1);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     query = new FuzzyQuery(new Term("field", "stellent"), FuzzyQuery.defaultMinSimilarity, 1);   
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     query = new FuzzyQuery(new Term("field", "student"), FuzzyQuery.defaultMinSimilarity, 2);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     query = new FuzzyQuery(new Term("field", "stellent"), FuzzyQuery.defaultMinSimilarity, 2);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     
     // "student" doesn't match anymore thanks to increased minimum similarity:
     query = new FuzzyQuery(new Term("field", "student"), 0.6f, 0);   
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     try {
       query = new FuzzyQuery(new Term("field", "student"), 1.1f);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java Fri May 23 11:57:55 2008
@@ -43,27 +43,27 @@
     iw.close();
     
     IndexSearcher is = new IndexSearcher(dir);
-    Hits hits = is.search(new MatchAllDocsQuery());
-    assertEquals(3, hits.length());
+    ScoreDoc[] hits = is.search(new MatchAllDocsQuery(), null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
 
     // some artificial queries to trigger the use of skipTo():
     
     BooleanQuery bq = new BooleanQuery();
     bq.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
     bq.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
-    hits = is.search(bq);
-    assertEquals(3, hits.length());
+    hits = is.search(bq, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
 
     bq = new BooleanQuery();
     bq.add(new MatchAllDocsQuery(), BooleanClause.Occur.MUST);
     bq.add(new TermQuery(new Term("key", "three")), BooleanClause.Occur.MUST);
-    hits = is.search(bq);
-    assertEquals(1, hits.length());
+    hits = is.search(bq, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     // delete a document:
     is.getIndexReader().deleteDocument(0);
-    hits = is.search(new MatchAllDocsQuery());
-    assertEquals(2, hits.length());
+    hits = is.search(new MatchAllDocsQuery(), null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
     
     is.close();
   }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java Fri May 23 11:57:55 2008
@@ -85,11 +85,11 @@
         query2.add((Term[])termsWithPrefix.toArray(new Term[0]));
         assertEquals("body:\"strawberry (piccadilly pie pizza)\"", query2.toString());
 
-        Hits result;
-        result = searcher.search(query1);
-        assertEquals(2, result.length());
-        result = searcher.search(query2);
-        assertEquals(0, result.length());
+        ScoreDoc[] result;
+        result = searcher.search(query1, null, 1000).scoreDocs;
+        assertEquals(2, result.length);
+        result = searcher.search(query2, null, 1000).scoreDocs;
+        assertEquals(0, result.length);
 
         // search for "blue* pizza":
         MultiPhraseQuery query3 = new MultiPhraseQuery();
@@ -105,14 +105,14 @@
         query3.add((Term[])termsWithPrefix.toArray(new Term[0]));
         query3.add(new Term("body", "pizza"));
 
-        result = searcher.search(query3);
-        assertEquals(2, result.length()); // blueberry pizza, bluebird pizza
+        result = searcher.search(query3, null, 1000).scoreDocs;
+        assertEquals(2, result.length); // blueberry pizza, bluebird pizza
         assertEquals("body:\"(blueberry bluebird) pizza\"", query3.toString());
 
         // test slop:
         query3.setSlop(1);
-        result = searcher.search(query3);
-        assertEquals(3, result.length()); // blueberry pizza, bluebird pizza, bluebird foobar pizza
+        result = searcher.search(query3, null, 1000).scoreDocs;
+        assertEquals(3, result.length); // blueberry pizza, bluebird pizza, bluebird foobar pizza
 
         MultiPhraseQuery query4 = new MultiPhraseQuery();
         try {
@@ -161,9 +161,9 @@
       q.add(trouble, BooleanClause.Occur.MUST);
 
       // exception will be thrown here without fix
-      Hits hits = searcher.search(q);
+      ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
 
-      assertEquals("Wrong number of hits", 2, hits.length());
+      assertEquals("Wrong number of hits", 2, hits.length);
       searcher.close();
   }
     
@@ -186,8 +186,8 @@
     q.add(trouble, BooleanClause.Occur.MUST);
 
     // exception will be thrown here without fix for #35626:
-    Hits hits = searcher.search(q);
-    assertEquals("Wrong number of hits", 0, hits.length());
+    ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals("Wrong number of hits", 0, hits.length);
     searcher.close();
   }
   

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java Fri May 23 11:57:55 2008
@@ -114,13 +114,13 @@
         // creating the multiSearcher
         Searcher mSearcher = getMultiSearcherInstance(searchers);
         // performing the search
-        Hits hits = mSearcher.search(query);
+        ScoreDoc[] hits = mSearcher.search(query, null, 1000).scoreDocs;
 
-        assertEquals(3, hits.length());
+        assertEquals(3, hits.length);
 
         // iterating over the hit documents
-        for (int i = 0; i < hits.length(); i++) {
-            Document d = hits.doc(i);
+        for (int i = 0; i < hits.length; i++) {
+            Document d = mSearcher.doc(hits[i].doc);
         }
         mSearcher.close();
 
@@ -143,26 +143,26 @@
         // creating the mulitSearcher
         MultiSearcher mSearcher2 = getMultiSearcherInstance(searchers2);
         // performing the same search
-        Hits hits2 = mSearcher2.search(query);
+        ScoreDoc[] hits2 = mSearcher2.search(query, null, 1000).scoreDocs;
 
-        assertEquals(4, hits2.length());
+        assertEquals(4, hits2.length);
 
         // iterating over the hit documents
-        for (int i = 0; i < hits2.length(); i++) {
+        for (int i = 0; i < hits2.length; i++) {
             // no exception should happen at this point
-            Document d = hits2.doc(i);
+            Document d = mSearcher2.doc(hits2[i].doc);
         }
 
         // test the subSearcher() method:
         Query subSearcherQuery = parser.parse("id:doc1");
-        hits2 = mSearcher2.search(subSearcherQuery);
-        assertEquals(2, hits2.length());
-        assertEquals(0, mSearcher2.subSearcher(hits2.id(0)));   // hit from searchers2[0]
-        assertEquals(1, mSearcher2.subSearcher(hits2.id(1)));   // hit from searchers2[1]
+        hits2 = mSearcher2.search(subSearcherQuery, null, 1000).scoreDocs;
+        assertEquals(2, hits2.length);
+        assertEquals(0, mSearcher2.subSearcher(hits2[0].doc));   // hit from searchers2[0]
+        assertEquals(1, mSearcher2.subSearcher(hits2[1].doc));   // hit from searchers2[1]
         subSearcherQuery = parser.parse("id:doc2");
-        hits2 = mSearcher2.search(subSearcherQuery);
-        assertEquals(1, hits2.length());
-        assertEquals(1, mSearcher2.subSearcher(hits2.id(0)));   // hit from searchers2[1]
+        hits2 = mSearcher2.search(subSearcherQuery, null, 1000).scoreDocs;
+        assertEquals(1, hits2.length);
+        assertEquals(1, mSearcher2.subSearcher(hits2[0].doc));   // hit from searchers2[1]
         mSearcher2.close();
 
         //--------------------------------------------------------------------
@@ -188,13 +188,13 @@
         // creating the mulitSearcher
         Searcher mSearcher3 = getMultiSearcherInstance(searchers3);
         // performing the same search
-        Hits hits3 = mSearcher3.search(query);
+        ScoreDoc[] hits3 = mSearcher3.search(query, null, 1000).scoreDocs;
 
-        assertEquals(3, hits3.length());
+        assertEquals(3, hits3.length);
 
         // iterating over the hit documents
-        for (int i = 0; i < hits3.length(); i++) {
-            Document d = hits3.doc(i);
+        for (int i = 0; i < hits3.length; i++) {
+            Document d = mSearcher3.doc(hits3[i].doc);
         }
         mSearcher3.close();
         indexStoreA.close();
@@ -246,10 +246,10 @@
 
     MultiSearcher searcher = getMultiSearcherInstance(new Searcher[]{indexSearcher1, indexSearcher2});
     assertTrue("searcher is null and it shouldn't be", searcher != null);
-    Hits hits = searcher.search(query);
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
     assertTrue("hits is null and it shouldn't be", hits != null);
-    assertTrue(hits.length() + " does not equal: " + 2, hits.length() == 2);
-    Document document = searcher.doc(hits.id(0));
+    assertTrue(hits.length + " does not equal: " + 2, hits.length == 2);
+    Document document = searcher.doc(hits[0].doc);
     assertTrue("document is null and it shouldn't be", document != null);
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 2, document.getFields().size() == 2);
     //Should be one document from each directory
@@ -257,7 +257,7 @@
     Set ftl = new HashSet();
     ftl.add("other");
     SetBasedFieldSelector fs = new SetBasedFieldSelector(ftl, Collections.EMPTY_SET);
-    document = searcher.doc(hits.id(0), fs);
+    document = searcher.doc(hits[0].doc, fs);
     assertTrue("document is null and it shouldn't be", document != null);
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 1, document.getFields().size() == 1);
     String value = document.get("contents");
@@ -267,7 +267,7 @@
     ftl.clear();
     ftl.add("contents");
     fs = new SetBasedFieldSelector(ftl, Collections.EMPTY_SET);
-    document = searcher.doc(hits.id(1), fs);
+    document = searcher.doc(hits[1].doc, fs);
     value = document.get("contents");
     assertTrue("value is null and it shouldn't be", value != null);    
     value = document.get("other");
@@ -289,7 +289,7 @@
         
         RAMDirectory ramDirectory1;
         IndexSearcher indexSearcher1;
-        Hits hits;
+        ScoreDoc[] hits;
         
         ramDirectory1=new MockRAMDirectory();
         
@@ -299,14 +299,12 @@
         
         indexSearcher1=new IndexSearcher(ramDirectory1);
         
-        hits=indexSearcher1.search(query);
+        hits=indexSearcher1.search(query, null, 1000).scoreDocs;
         
-        assertEquals(message, 2, hits.length());
-        
-        assertEquals(message, 1, hits.score(0), 1e-6); // hits.score(0) is 0.594535 if only a single document is in first index
+        assertEquals(message, 2, hits.length);
         
         // Store the scores for use later
-        float[] scores={ hits.score(0), hits.score(1) };
+        float[] scores={ hits[0].score, hits[1].score };
         
         assertTrue(message, scores[0] > scores[1]);
         
@@ -331,23 +329,23 @@
         
         Searcher searcher=getMultiSearcherInstance(new Searcher[] { indexSearcher1, indexSearcher2 });
         
-        hits=searcher.search(query);
+        hits=searcher.search(query, null, 1000).scoreDocs;
         
-        assertEquals(message, 2, hits.length());
+        assertEquals(message, 2, hits.length);
         
         // The scores should be the same (within reason)
-        assertEquals(message, scores[0], hits.score(0), 1e-6); // This will a document from ramDirectory1
-        assertEquals(message, scores[1], hits.score(1), 1e-6); // This will a document from ramDirectory2
+        assertEquals(message, scores[0], hits[0].score, 1e-6); // This will a document from ramDirectory1
+        assertEquals(message, scores[1], hits[1].score, 1e-6); // This will a document from ramDirectory2
         
         
         
         // Adding a Sort.RELEVANCE object should not change anything
-        hits=searcher.search(query, Sort.RELEVANCE);
+        hits=searcher.search(query, null, 1000, Sort.RELEVANCE).scoreDocs;
         
-        assertEquals(message, 2, hits.length());
+        assertEquals(message, 2, hits.length);
         
-        assertEquals(message, scores[0], hits.score(0), 1e-6); // This will a document from ramDirectory1
-        assertEquals(message, scores[1], hits.score(1), 1e-6); // This will a document from ramDirectory2
+        assertEquals(message, scores[0], hits[0].score, 1e-6); // This will a document from ramDirectory1
+        assertEquals(message, scores[1], hits[1].score, 1e-6); // This will a document from ramDirectory2
         
         searcher.close();
         

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java Fri May 23 11:57:55 2008
@@ -90,17 +90,17 @@
     if(verbose) System.out.println("Query: " + queryStr);
       QueryParser queryParser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
     Query query = queryParser.parse(queryStr);
-    Hits multiSearcherHits = multiSearcher.search(query);
-    Hits singleSearcherHits = singleSearcher.search(query);
-    assertEquals(multiSearcherHits.length(), singleSearcherHits.length());
-    for (int i = 0; i < multiSearcherHits.length(); i++) {
-      Document docMulti = multiSearcherHits.doc(i);
-      Document docSingle = singleSearcherHits.doc(i);
+    ScoreDoc[] multiSearcherHits = multiSearcher.search(query, null, 1000).scoreDocs;
+    ScoreDoc[] singleSearcherHits = singleSearcher.search(query, null, 1000).scoreDocs;
+    assertEquals(multiSearcherHits.length, singleSearcherHits.length);
+    for (int i = 0; i < multiSearcherHits.length; i++) {
+      Document docMulti = multiSearcher.doc(multiSearcherHits[i].doc);
+      Document docSingle = singleSearcher.doc(singleSearcherHits[i].doc);
       if(verbose) System.out.println("Multi:  " + docMulti.get(FIELD_NAME) + " score="
-          + multiSearcherHits.score(i));
+          + multiSearcherHits[i].score);
       if(verbose) System.out.println("Single: " + docSingle.get(FIELD_NAME) + " score="
-          + singleSearcherHits.score(i));
-      assertEquals(multiSearcherHits.score(i), singleSearcherHits.score(i),
+          + singleSearcherHits[i].score);
+      assertEquals(multiSearcherHits[i].score, singleSearcherHits[i].score,
           0.001f);
       assertEquals(docMulti.get(FIELD_NAME), docSingle.get(FIELD_NAME));
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java Fri May 23 11:57:55 2008
@@ -51,7 +51,7 @@
       QueryParser parser = new QueryParser("field", new SimpleAnalyzer());
     Query query = parser.parse("a NOT b");
     //System.out.println(query);
-    Hits hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
   }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java Fri May 23 11:57:55 2008
@@ -95,11 +95,11 @@
         query1.add((Term[])termsWithPrefix.toArray(new Term[0]));
         query2.add((Term[])termsWithPrefix.toArray(new Term[0]));
 
-        Hits result;
-        result = searcher.search(query1);
-        assertEquals(2, result.length());
+        ScoreDoc[] result;
+        result = searcher.search(query1, null, 1000).scoreDocs;
+        assertEquals(2, result.length);
 
-        result = searcher.search(query2);
-        assertEquals(0, result.length());
+        result = searcher.search(query2, null, 1000).scoreDocs;
+        assertEquals(0, result.length);
     }
 }



Mime
View raw message