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 [3/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/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPhraseQuery.java Fri May 23 11:57:55 2008
@@ -91,8 +91,8 @@
     query.setSlop(2);
     query.add(new Term("field", "one"));
     query.add(new Term("field", "five"));
-    Hits hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
     QueryUtils.check(query,searcher);
   }
 
@@ -100,8 +100,8 @@
     query.setSlop(3);
     query.add(new Term("field", "one"));
     query.add(new Term("field", "five"));
-    Hits hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     QueryUtils.check(query,searcher);
   }
 
@@ -112,16 +112,16 @@
     // slop is zero by default
     query.add(new Term("field", "four"));
     query.add(new Term("field", "five"));
-    Hits hits = searcher.search(query);
-    assertEquals("exact match", 1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("exact match", 1, hits.length);
     QueryUtils.check(query,searcher);
 
 
     query = new PhraseQuery();
     query.add(new Term("field", "two"));
     query.add(new Term("field", "one"));
-    hits = searcher.search(query);
-    assertEquals("reverse not exact", 0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("reverse not exact", 0, hits.length);
     QueryUtils.check(query,searcher);
   }
 
@@ -130,8 +130,8 @@
     query.setSlop(1);
     query.add(new Term("field", "one"));
     query.add(new Term("field", "two"));
-    Hits hits = searcher.search(query);
-    assertEquals("in order", 1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("in order", 1, hits.length);
     QueryUtils.check(query,searcher);
 
 
@@ -141,8 +141,8 @@
     query.setSlop(1);
     query.add(new Term("field", "two"));
     query.add(new Term("field", "one"));
-    hits = searcher.search(query);
-    assertEquals("reversed, slop not 2 or more", 0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("reversed, slop not 2 or more", 0, hits.length);
     QueryUtils.check(query,searcher);
   }
 
@@ -153,8 +153,8 @@
     query.setSlop(2); // must be at least two for reverse order match
     query.add(new Term("field", "two"));
     query.add(new Term("field", "one"));
-    Hits hits = searcher.search(query);
-    assertEquals("just sloppy enough", 1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("just sloppy enough", 1, hits.length);
     QueryUtils.check(query,searcher);
 
 
@@ -162,8 +162,8 @@
     query.setSlop(2);
     query.add(new Term("field", "three"));
     query.add(new Term("field", "one"));
-    hits = searcher.search(query);
-    assertEquals("not sloppy enough", 0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("not sloppy enough", 0, hits.length);
     QueryUtils.check(query,searcher);
 
   }
@@ -177,8 +177,8 @@
     query.add(new Term("field", "one"));
     query.add(new Term("field", "three"));
     query.add(new Term("field", "five"));
-    Hits hits = searcher.search(query);
-    assertEquals("two total moves", 1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("two total moves", 1, hits.length);
     QueryUtils.check(query,searcher);
 
 
@@ -187,14 +187,14 @@
     query.add(new Term("field", "five"));
     query.add(new Term("field", "three"));
     query.add(new Term("field", "one"));
-    hits = searcher.search(query);
-    assertEquals("slop of 5 not close enough", 0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("slop of 5 not close enough", 0, hits.length);
     QueryUtils.check(query,searcher);
 
 
     query.setSlop(6);
-    hits = searcher.search(query);
-    assertEquals("slop of 6 just right", 1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("slop of 6 just right", 1, hits.length);
     QueryUtils.check(query,searcher);
 
   }
@@ -215,8 +215,8 @@
     PhraseQuery query = new PhraseQuery();
     query.add(new Term("field","stop"));
     query.add(new Term("field","words"));
-    Hits hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     QueryUtils.check(query,searcher);
 
 
@@ -224,8 +224,8 @@
     query = new PhraseQuery();
     query.add(new Term("field", "words"));
     query.add(new Term("field", "here"));
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     QueryUtils.check(query,searcher);
 
 
@@ -254,8 +254,8 @@
     PhraseQuery phraseQuery = new PhraseQuery();
     phraseQuery.add(new Term("source", "marketing"));
     phraseQuery.add(new Term("source", "info"));
-    Hits hits = searcher.search(phraseQuery);
-    assertEquals(2, hits.length());
+    ScoreDoc[] hits = searcher.search(phraseQuery, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
     QueryUtils.check(phraseQuery,searcher);
 
     
@@ -263,8 +263,8 @@
     BooleanQuery booleanQuery = new BooleanQuery();
     booleanQuery.add(termQuery, BooleanClause.Occur.MUST);
     booleanQuery.add(phraseQuery, BooleanClause.Occur.MUST);
-    hits = searcher.search(booleanQuery);
-    assertEquals(1, hits.length());
+    hits = searcher.search(booleanQuery, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
     QueryUtils.check(termQuery,searcher);
 
     
@@ -294,23 +294,23 @@
     phraseQuery.add(new Term("contents","map"));
     phraseQuery.add(new Term("contents","entry"));
     
-    hits = searcher.search(termQuery);
-    assertEquals(3, hits.length());
-    hits = searcher.search(phraseQuery);
-    assertEquals(2, hits.length());
+    hits = searcher.search(termQuery, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
+    hits = searcher.search(phraseQuery, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
 
     
     booleanQuery = new BooleanQuery();
     booleanQuery.add(termQuery, BooleanClause.Occur.MUST);
     booleanQuery.add(phraseQuery, BooleanClause.Occur.MUST);
-    hits = searcher.search(booleanQuery);
-    assertEquals(2, hits.length());
+    hits = searcher.search(booleanQuery, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
     
     booleanQuery = new BooleanQuery();
     booleanQuery.add(phraseQuery, BooleanClause.Occur.MUST);
     booleanQuery.add(termQuery, BooleanClause.Occur.MUST);
-    hits = searcher.search(booleanQuery);
-    assertEquals(2, hits.length());
+    hits = searcher.search(booleanQuery, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
     QueryUtils.check(booleanQuery,searcher);
 
     
@@ -343,16 +343,16 @@
     query.add(new Term("field", "firstname"));
     query.add(new Term("field", "lastname"));
     query.setSlop(Integer.MAX_VALUE);
-    Hits hits = searcher.search(query);
-    assertEquals(3, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(3, hits.length);
     // Make sure that those matches where the terms appear closer to
     // each other get a higher score:
-    assertEquals(0.71, hits.score(0), 0.01);
-    assertEquals(0, hits.id(0));
-    assertEquals(0.44, hits.score(1), 0.01);
-    assertEquals(1, hits.id(1));
-    assertEquals(0.31, hits.score(2), 0.01);
-    assertEquals(2, hits.id(2));
+    assertEquals(0.71, hits[0].score, 0.01);
+    assertEquals(0, hits[0].doc);
+    assertEquals(0.44, hits[1].score, 0.01);
+    assertEquals(1, hits[1].doc);
+    assertEquals(0.31, hits[2].score, 0.01);
+    assertEquals(2, hits[2].doc);
     QueryUtils.check(query,searcher);        
   }
 
@@ -363,14 +363,14 @@
     query.add(new Term("repeated", "part"));
     query.setSlop(100);
 
-    Hits hits = searcher.search(query);
-    assertEquals("slop of 100 just right", 1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("slop of 100 just right", 1, hits.length);
     QueryUtils.check(query,searcher);
 
     query.setSlop(99);
 
-    hits = searcher.search(query);
-    assertEquals("slop of 99 not enough", 0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("slop of 99 not enough", 0, hits.length);
     QueryUtils.check(query,searcher);
   }
 
@@ -382,8 +382,8 @@
     query.add(new Term("nonexist", "found"));
     query.setSlop(2); // would be found this way
 
-    Hits hits = searcher.search(query);
-    assertEquals("phrase without repetitions exists in 2 docs", 2, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("phrase without repetitions exists in 2 docs", 2, hits.length);
     QueryUtils.check(query,searcher);
 
     // phrase with repetitions that exists in 2 docs
@@ -393,8 +393,8 @@
     query.add(new Term("nonexist", "exist"));
     query.setSlop(1); // would be found 
 
-    hits = searcher.search(query);
-    assertEquals("phrase with repetitions exists in two docs", 2, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("phrase with repetitions exists in two docs", 2, hits.length);
     QueryUtils.check(query,searcher);
 
     // phrase I with repetitions that does not exist in any doc
@@ -404,8 +404,8 @@
     query.add(new Term("nonexist", "phrase"));
     query.setSlop(1000); // would not be found no matter how high the slop is
 
-    hits = searcher.search(query);
-    assertEquals("nonexisting phrase with repetitions does not exist in any doc", 0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("nonexisting phrase with repetitions does not exist in any doc", 0, hits.length);
     QueryUtils.check(query,searcher);
 
     // phrase II with repetitions that does not exist in any doc
@@ -416,8 +416,8 @@
     query.add(new Term("nonexist", "exist"));
     query.setSlop(1000); // would not be found no matter how high the slop is
 
-    hits = searcher.search(query);
-    assertEquals("nonexisting phrase with repetitions does not exist in any doc", 0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("nonexisting phrase with repetitions does not exist in any doc", 0, hits.length);
     QueryUtils.check(query,searcher);
 
   }
@@ -437,17 +437,17 @@
     query.setSlop(0); // to use exact phrase scorer
     query.add(new Term("field", "two"));
     query.add(new Term("field", "three"));
-    Hits hits = searcher.search(query);
-    assertEquals("phrase found with exact phrase scorer", 1, hits.length());
-    float score0 = hits.score(0);
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("phrase found with exact phrase scorer", 1, hits.length);
+    float score0 = hits[0].score;
     //System.out.println("(exact) field: two three: "+score0);
     QueryUtils.check(query,searcher);
 
     // search on non palyndrome, find phrase with slop 2, though no slop required here.
     query.setSlop(2); // to use sloppy scorer 
-    hits = searcher.search(query);
-    assertEquals("just sloppy enough", 1, hits.length());
-    float score1 = hits.score(0);
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("just sloppy enough", 1, hits.length);
+    float score1 = hits[0].score;
     //System.out.println("(sloppy) field: two three: "+score1);
     assertEquals("exact scorer and sloppy scorer score the same when slop does not matter",score0, score1, SCORE_COMP_THRESH);
     QueryUtils.check(query,searcher);
@@ -457,9 +457,9 @@
     query.setSlop(2); // must be at least two for both ordered and reversed to match
     query.add(new Term("palindrome", "two"));
     query.add(new Term("palindrome", "three"));
-    hits = searcher.search(query);
-    assertEquals("just sloppy enough", 1, hits.length());
-    float score2 = hits.score(0);
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("just sloppy enough", 1, hits.length);
+    float score2 = hits[0].score;
     //System.out.println("palindrome: two three: "+score2);
     QueryUtils.check(query,searcher);
     
@@ -471,9 +471,9 @@
     query.setSlop(2); // must be at least two for both ordered and reversed to match
     query.add(new Term("palindrome", "three"));
     query.add(new Term("palindrome", "two"));
-    hits = searcher.search(query);
-    assertEquals("just sloppy enough", 1, hits.length());
-    float score3 = hits.score(0);
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("just sloppy enough", 1, hits.length);
+    float score3 = hits[0].score;
     //System.out.println("palindrome: three two: "+score3);
     QueryUtils.check(query,searcher);
 
@@ -498,17 +498,17 @@
     query.add(new Term("field", "one"));
     query.add(new Term("field", "two"));
     query.add(new Term("field", "three"));
-    Hits hits = searcher.search(query);
-    assertEquals("phrase found with exact phrase scorer", 1, hits.length());
-    float score0 = hits.score(0);
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("phrase found with exact phrase scorer", 1, hits.length);
+    float score0 = hits[0].score;
     //System.out.println("(exact) field: one two three: "+score0);
     QueryUtils.check(query,searcher);
 
     // search on non palyndrome, find phrase with slop 3, though no slop required here.
     query.setSlop(4); // to use sloppy scorer 
-    hits = searcher.search(query);
-    assertEquals("just sloppy enough", 1, hits.length());
-    float score1 = hits.score(0);
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("just sloppy enough", 1, hits.length);
+    float score1 = hits[0].score;
     //System.out.println("(sloppy) field: one two three: "+score1);
     assertEquals("exact scorer and sloppy scorer score the same when slop does not matter",score0, score1, SCORE_COMP_THRESH);
     QueryUtils.check(query,searcher);
@@ -519,9 +519,9 @@
     query.add(new Term("palindrome", "one"));
     query.add(new Term("palindrome", "two"));
     query.add(new Term("palindrome", "three"));
-    hits = searcher.search(query);
-    assertEquals("just sloppy enough", 1, hits.length());
-    float score2 = hits.score(0);
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("just sloppy enough", 1, hits.length);
+    float score2 = hits[0].score;
     //System.out.println("palindrome: one two three: "+score2);
     QueryUtils.check(query,searcher);
     
@@ -534,9 +534,9 @@
     query.add(new Term("palindrome", "three"));
     query.add(new Term("palindrome", "two"));
     query.add(new Term("palindrome", "one"));
-    hits = searcher.search(query);
-    assertEquals("just sloppy enough", 1, hits.length());
-    float score3 = hits.score(0);
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("just sloppy enough", 1, hits.length);
+    float score3 = hits[0].score;
     //System.out.println("palindrome: three two one: "+score3);
     QueryUtils.check(query,searcher);
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPositionIncrement.java Fri May 23 11:57:55 2008
@@ -17,25 +17,20 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.search.PhraseQuery;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.store.RAMDirectory;
+import java.io.Reader;
+import java.io.StringReader;
+
 import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.analysis.StopAnalyzer;
 import org.apache.lucene.analysis.StopFilter;
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-
-import java.io.Reader;
-import java.io.StringReader;
-
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.queryParser.QueryParser;
+import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.LuceneTestCase;
 
 /**
@@ -76,85 +71,85 @@
 
     IndexSearcher searcher = new IndexSearcher(store);
     PhraseQuery q;
-    Hits hits;
+    ScoreDoc[] hits;
 
     q = new PhraseQuery();
     q.add(new Term("field", "1"));
     q.add(new Term("field", "2"));
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // same as previous, just specify positions explicitely.
     q = new PhraseQuery(); 
     q.add(new Term("field", "1"),0);
     q.add(new Term("field", "2"),1);
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // specifying correct positions should find the phrase.
     q = new PhraseQuery();
     q.add(new Term("field", "1"),0);
     q.add(new Term("field", "2"),2);
-    hits = searcher.search(q);
-    assertEquals(1, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     q = new PhraseQuery();
     q.add(new Term("field", "2"));
     q.add(new Term("field", "3"));
-    hits = searcher.search(q);
-    assertEquals(1, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     q = new PhraseQuery();
     q.add(new Term("field", "3"));
     q.add(new Term("field", "4"));
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // phrase query would find it when correct positions are specified. 
     q = new PhraseQuery();
     q.add(new Term("field", "3"),0);
     q.add(new Term("field", "4"),0);
-    hits = searcher.search(q);
-    assertEquals(1, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     // phrase query should fail for non existing searched term 
     // even if there exist another searched terms in the same searched position. 
     q = new PhraseQuery();
     q.add(new Term("field", "3"),0);
     q.add(new Term("field", "9"),0);
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // multi-phrase query should succed for non existing searched term
     // because there exist another searched terms in the same searched position. 
     MultiPhraseQuery mq = new MultiPhraseQuery();
     mq.add(new Term[]{new Term("field", "3"),new Term("field", "9")},0);
-    hits = searcher.search(mq);
-    assertEquals(1, hits.length());
+    hits = searcher.search(mq, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     q = new PhraseQuery();
     q.add(new Term("field", "2"));
     q.add(new Term("field", "4"));
-    hits = searcher.search(q);
-    assertEquals(1, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     q = new PhraseQuery();
     q.add(new Term("field", "3"));
     q.add(new Term("field", "5"));
-    hits = searcher.search(q);
-    assertEquals(1, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     q = new PhraseQuery();
     q.add(new Term("field", "4"));
     q.add(new Term("field", "5"));
-    hits = searcher.search(q);
-    assertEquals(1, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     q = new PhraseQuery();
     q.add(new Term("field", "2"));
     q.add(new Term("field", "5"));
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // analyzer to introduce stopwords and increment gaps 
     Analyzer stpa = new Analyzer() {
@@ -168,19 +163,19 @@
     // should not find "1 2" because there is a gap of 1 in the index
     QueryParser qp = new QueryParser("field",stpa);
     q = (PhraseQuery) qp.parse("\"1 2\"");
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // omitted stop word cannot help because stop filter swallows the increments. 
     q = (PhraseQuery) qp.parse("\"1 stop 2\"");
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // query parser alone won't help, because stop filter swallows the increments. 
     qp.setEnablePositionIncrements(true);
     q = (PhraseQuery) qp.parse("\"1 stop 2\"");
-    hits = searcher.search(q);
-    assertEquals(0, hits.length());
+    hits = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     boolean dflt = StopFilter.getEnablePositionIncrementsDefault();
     try {
@@ -188,14 +183,14 @@
       qp.setEnablePositionIncrements(false);
       StopFilter.setEnablePositionIncrementsDefault(true);
       q = (PhraseQuery) qp.parse("\"1 stop 2\"");
-      hits = searcher.search(q);
-      assertEquals(0, hits.length());
+      hits = searcher.search(q, null, 1000).scoreDocs;
+      assertEquals(0, hits.length);
       
       // when both qp qnd stopFilter propagate increments, we should find the doc.
       qp.setEnablePositionIncrements(true);
       q = (PhraseQuery) qp.parse("\"1 stop 2\"");
-      hits = searcher.search(q);
-      assertEquals(1, hits.length());
+      hits = searcher.search(q, null, 1000).scoreDocs;
+      assertEquals(1, hits.length);
     } finally {
       StopFilter.setEnablePositionIncrementsDefault(dflt);
     }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixFilter.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixFilter.java Fri May 23 11:57:55 2008
@@ -51,55 +51,55 @@
     PrefixFilter filter = new PrefixFilter(new Term("category", "/Computers"));
     Query query = new ConstantScoreQuery(filter);
     IndexSearcher searcher = new IndexSearcher(directory);
-    Hits hits = searcher.search(query);
-    assertEquals(4, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(4, hits.length);
 
     // test middle of values
     filter = new PrefixFilter(new Term("category", "/Computers/Mac"));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(2, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(2, hits.length);
 
     // test start of values
     filter = new PrefixFilter(new Term("category", "/Computers/Linux"));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     // test end of values
     filter = new PrefixFilter(new Term("category", "/Computers/Windows"));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
     // test non-existant
     filter = new PrefixFilter(new Term("category", "/Computers/ObsoleteOS"));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // test non-existant, before values
     filter = new PrefixFilter(new Term("category", "/Computers/AAA"));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // test non-existant, after values
     filter = new PrefixFilter(new Term("category", "/Computers/ZZZ"));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
 
     // test zero length prefix
     filter = new PrefixFilter(new Term("category", ""));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(4, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(4, hits.length);
 
     // test non existent field
     filter = new PrefixFilter(new Term("nonexistantfield", "/Computers"));
     query = new ConstantScoreQuery(filter);
-    hits = searcher.search(query);
-    assertEquals(0, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(0, hits.length);
   }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPrefixQuery.java Fri May 23 11:57:55 2008
@@ -47,11 +47,11 @@
 
     PrefixQuery query = new PrefixQuery(new Term("category", "/Computers"));
     IndexSearcher searcher = new IndexSearcher(directory);
-    Hits hits = searcher.search(query);
-    assertEquals("All documents in /Computers category and below", 3, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("All documents in /Computers category and below", 3, hits.length);
 
     query = new PrefixQuery(new Term("category", "/Computers/Mac"));
-    hits = searcher.search(query);
-    assertEquals("One in /Computers/Mac", 1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("One in /Computers/Mac", 1, hits.length);
   }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeFilter.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeFilter.java Fri May 23 11:57:55 2008
@@ -55,70 +55,70 @@
         
         assertEquals("num of docs", numDocs, 1+ maxId - minId);
         
-	Hits result;
+  ScoreDoc[] result;
         Query q = new TermQuery(new Term("body","body"));
 
         // test id, bounded on both ends
         
-	result = search.search(q,new RangeFilter("id",minIP,maxIP,T,T));
-	assertEquals("find all", numDocs, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,maxIP,T,T), numDocs).scoreDocs;
+  assertEquals("find all", numDocs, result.length);
 
-	result = search.search(q,new RangeFilter("id",minIP,maxIP,T,F));
-	assertEquals("all but last", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,maxIP,T,F), numDocs).scoreDocs;
+  assertEquals("all but last", numDocs-1, result.length);
 
-	result = search.search(q,new RangeFilter("id",minIP,maxIP,F,T));
-	assertEquals("all but first", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,maxIP,F,T), numDocs).scoreDocs;
+  assertEquals("all but first", numDocs-1, result.length);
         
-	result = search.search(q,new RangeFilter("id",minIP,maxIP,F,F));
-        assertEquals("all but ends", numDocs-2, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,maxIP,F,F), numDocs).scoreDocs;
+        assertEquals("all but ends", numDocs-2, result.length);
     
-        result = search.search(q,new RangeFilter("id",medIP,maxIP,T,T));
-        assertEquals("med and up", 1+ maxId-medId, result.length());
+        result = search.search(q,new RangeFilter("id",medIP,maxIP,T,T), numDocs).scoreDocs;
+        assertEquals("med and up", 1+ maxId-medId, result.length);
         
-        result = search.search(q,new RangeFilter("id",minIP,medIP,T,T));
-        assertEquals("up to med", 1+ medId-minId, result.length());
+        result = search.search(q,new RangeFilter("id",minIP,medIP,T,T), numDocs).scoreDocs;
+        assertEquals("up to med", 1+ medId-minId, result.length);
 
         // unbounded id
 
-	result = search.search(q,new RangeFilter("id",minIP,null,T,F));
-	assertEquals("min and up", numDocs, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,null,T,F), numDocs).scoreDocs;
+  assertEquals("min and up", numDocs, result.length);
 
-	result = search.search(q,new RangeFilter("id",null,maxIP,F,T));
-	assertEquals("max and down", numDocs, result.length());
+  result = search.search(q,new RangeFilter("id",null,maxIP,F,T), numDocs).scoreDocs;
+  assertEquals("max and down", numDocs, result.length);
 
-	result = search.search(q,new RangeFilter("id",minIP,null,F,F));
-	assertEquals("not min, but up", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,null,F,F), numDocs).scoreDocs;
+  assertEquals("not min, but up", numDocs-1, result.length);
         
-	result = search.search(q,new RangeFilter("id",null,maxIP,F,F));
-	assertEquals("not max, but down", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("id",null,maxIP,F,F), numDocs).scoreDocs;
+  assertEquals("not max, but down", numDocs-1, result.length);
         
-        result = search.search(q,new RangeFilter("id",medIP,maxIP,T,F));
-        assertEquals("med and up, not max", maxId-medId, result.length());
+        result = search.search(q,new RangeFilter("id",medIP,maxIP,T,F), numDocs).scoreDocs;
+        assertEquals("med and up, not max", maxId-medId, result.length);
         
-        result = search.search(q,new RangeFilter("id",minIP,medIP,F,T));
-        assertEquals("not min, up to med", medId-minId, result.length());
+        result = search.search(q,new RangeFilter("id",minIP,medIP,F,T), numDocs).scoreDocs;
+        assertEquals("not min, up to med", medId-minId, result.length);
 
         // very small sets
 
-	result = search.search(q,new RangeFilter("id",minIP,minIP,F,F));
-	assertEquals("min,min,F,F", 0, result.length());
-	result = search.search(q,new RangeFilter("id",medIP,medIP,F,F));
-	assertEquals("med,med,F,F", 0, result.length());
-	result = search.search(q,new RangeFilter("id",maxIP,maxIP,F,F));
-	assertEquals("max,max,F,F", 0, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,minIP,F,F), numDocs).scoreDocs;
+  assertEquals("min,min,F,F", 0, result.length);
+  result = search.search(q,new RangeFilter("id",medIP,medIP,F,F), numDocs).scoreDocs;
+  assertEquals("med,med,F,F", 0, result.length);
+  result = search.search(q,new RangeFilter("id",maxIP,maxIP,F,F), numDocs).scoreDocs;
+  assertEquals("max,max,F,F", 0, result.length);
                      
-	result = search.search(q,new RangeFilter("id",minIP,minIP,T,T));
-	assertEquals("min,min,T,T", 1, result.length());
-	result = search.search(q,new RangeFilter("id",null,minIP,F,T));
-	assertEquals("nul,min,F,T", 1, result.length());
-
-	result = search.search(q,new RangeFilter("id",maxIP,maxIP,T,T));
-	assertEquals("max,max,T,T", 1, result.length());
-	result = search.search(q,new RangeFilter("id",maxIP,null,T,F));
-	assertEquals("max,nul,T,T", 1, result.length());
+  result = search.search(q,new RangeFilter("id",minIP,minIP,T,T), numDocs).scoreDocs;
+  assertEquals("min,min,T,T", 1, result.length);
+  result = search.search(q,new RangeFilter("id",null,minIP,F,T), numDocs).scoreDocs;
+  assertEquals("nul,min,F,T", 1, result.length);
+
+  result = search.search(q,new RangeFilter("id",maxIP,maxIP,T,T), numDocs).scoreDocs;
+  assertEquals("max,max,T,T", 1, result.length);
+  result = search.search(q,new RangeFilter("id",maxIP,null,T,F), numDocs).scoreDocs;
+  assertEquals("max,nul,T,T", 1, result.length);
 
-	result = search.search(q,new RangeFilter("id",medIP,medIP,T,T));
-	assertEquals("med,med,T,T", 1, result.length());
+  result = search.search(q,new RangeFilter("id",medIP,medIP,T,T), numDocs).scoreDocs;
+  assertEquals("med,med,T,T", 1, result.length);
         
     }
 
@@ -134,53 +134,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(q,new RangeFilter("rand",minRP,maxRP,T,T));
-	assertEquals("find all", numDocs, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,maxRP,T,T), numDocs).scoreDocs;
+  assertEquals("find all", numDocs, result.length);
 
-	result = search.search(q,new RangeFilter("rand",minRP,maxRP,T,F));
-	assertEquals("all but biggest", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,maxRP,T,F), numDocs).scoreDocs;
+  assertEquals("all but biggest", numDocs-1, result.length);
 
-	result = search.search(q,new RangeFilter("rand",minRP,maxRP,F,T));
-	assertEquals("all but smallest", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,maxRP,F,T), numDocs).scoreDocs;
+  assertEquals("all but smallest", numDocs-1, result.length);
         
-	result = search.search(q,new RangeFilter("rand",minRP,maxRP,F,F));
-        assertEquals("all but extremes", numDocs-2, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,maxRP,F,F), numDocs).scoreDocs;
+        assertEquals("all but extremes", numDocs-2, result.length);
     
         // unbounded
 
-	result = search.search(q,new RangeFilter("rand",minRP,null,T,F));
-	assertEquals("smallest and up", numDocs, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,null,T,F), numDocs).scoreDocs;
+  assertEquals("smallest and up", numDocs, result.length);
 
-	result = search.search(q,new RangeFilter("rand",null,maxRP,F,T));
-	assertEquals("biggest and down", numDocs, result.length());
+  result = search.search(q,new RangeFilter("rand",null,maxRP,F,T), numDocs).scoreDocs;
+  assertEquals("biggest and down", numDocs, result.length);
 
-	result = search.search(q,new RangeFilter("rand",minRP,null,F,F));
-	assertEquals("not smallest, but up", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,null,F,F), numDocs).scoreDocs;
+  assertEquals("not smallest, but up", numDocs-1, result.length);
         
-	result = search.search(q,new RangeFilter("rand",null,maxRP,F,F));
-	assertEquals("not biggest, but down", numDocs-1, result.length());
+  result = search.search(q,new RangeFilter("rand",null,maxRP,F,F), numDocs).scoreDocs;
+  assertEquals("not biggest, but down", numDocs-1, result.length);
         
         // very small sets
 
-	result = search.search(q,new RangeFilter("rand",minRP,minRP,F,F));
-	assertEquals("min,min,F,F", 0, result.length());
-	result = search.search(q,new RangeFilter("rand",maxRP,maxRP,F,F));
-	assertEquals("max,max,F,F", 0, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,minRP,F,F), numDocs).scoreDocs;
+  assertEquals("min,min,F,F", 0, result.length);
+  result = search.search(q,new RangeFilter("rand",maxRP,maxRP,F,F), numDocs).scoreDocs;
+  assertEquals("max,max,F,F", 0, result.length);
                      
-	result = search.search(q,new RangeFilter("rand",minRP,minRP,T,T));
-	assertEquals("min,min,T,T", 1, result.length());
-	result = search.search(q,new RangeFilter("rand",null,minRP,F,T));
-	assertEquals("nul,min,F,T", 1, result.length());
-
-	result = search.search(q,new RangeFilter("rand",maxRP,maxRP,T,T));
-	assertEquals("max,max,T,T", 1, result.length());
-	result = search.search(q,new RangeFilter("rand",maxRP,null,T,F));
-	assertEquals("max,nul,T,T", 1, result.length());
+  result = search.search(q,new RangeFilter("rand",minRP,minRP,T,T), numDocs).scoreDocs;
+  assertEquals("min,min,T,T", 1, result.length);
+  result = search.search(q,new RangeFilter("rand",null,minRP,F,T), numDocs).scoreDocs;
+  assertEquals("nul,min,F,T", 1, result.length);
+
+  result = search.search(q,new RangeFilter("rand",maxRP,maxRP,T,T), numDocs).scoreDocs;
+  assertEquals("max,max,T,T", 1, result.length);
+  result = search.search(q,new RangeFilter("rand",maxRP,null,T,F), numDocs).scoreDocs;
+  assertEquals("max,nul,T,T", 1, result.length);
         
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestRangeQuery.java Fri May 23 11:57:55 2008
@@ -46,20 +46,20 @@
                                  false);
     initializeIndex(new String[] {"A", "B", "C", "D"});
     IndexSearcher searcher = new IndexSearcher(dir);
-    Hits hits = searcher.search(query);
-    assertEquals("A,B,C,D, only B in range", 1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("A,B,C,D, only B in range", 1, hits.length);
     searcher.close();
 
     initializeIndex(new String[] {"A", "B", "D"});
     searcher = new IndexSearcher(dir);
-    hits = searcher.search(query);
-    assertEquals("A,B,D, only B in range", 1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("A,B,D, only B in range", 1, hits.length);
     searcher.close();
 
     addDoc("C");
     searcher = new IndexSearcher(dir);
-    hits = searcher.search(query);
-    assertEquals("C added, still only B in range", 1, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("C added, still only B in range", 1, hits.length);
     searcher.close();
   }
 
@@ -70,20 +70,20 @@
 
     initializeIndex(new String[]{"A", "B", "C", "D"});
     IndexSearcher searcher = new IndexSearcher(dir);
-    Hits hits = searcher.search(query);
-    assertEquals("A,B,C,D - A,B,C in range", 3, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("A,B,C,D - A,B,C in range", 3, hits.length);
     searcher.close();
 
     initializeIndex(new String[]{"A", "B", "D"});
     searcher = new IndexSearcher(dir);
-    hits = searcher.search(query);
-    assertEquals("A,B,D - A and B in range", 2, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("A,B,D - A and B in range", 2, hits.length);
     searcher.close();
 
     addDoc("C");
     searcher = new IndexSearcher(dir);
-    hits = searcher.search(query);
-    assertEquals("C added - A, B, C in range", 3, hits.length());
+    hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals("C added - A, B, C in range", 3, hits.length);
     searcher.close();
   }
 
@@ -158,3 +158,4 @@
 }
 
 
+

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteCachingWrapperFilter.java Fri May 23 11:57:55 2008
@@ -81,9 +81,9 @@
   private static void search(Query query, Filter filter, int hitNumber, String typeValue) throws Exception {
     Searchable[] searchables = { getRemote() };
     Searcher searcher = new MultiSearcher(searchables);
-    Hits result = searcher.search(query,filter);
-    assertEquals(1, result.length());
-    Document document = result.doc(hitNumber);
+    ScoreDoc[] result = searcher.search(query,filter, 1000).scoreDocs;
+    assertEquals(1, result.length);
+    Document document = searcher.doc(result[hitNumber].doc);
     assertTrue("document is null and it shouldn't be", document != null);
     assertEquals(typeValue, document.get("type"));
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 3, document.getFields().size() == 3);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteSearchable.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteSearchable.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteSearchable.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestRemoteSearchable.java Fri May 23 11:57:55 2008
@@ -73,10 +73,10 @@
     // try to search the published index
     Searchable[] searchables = { getRemote() };
     Searcher searcher = new MultiSearcher(searchables);
-    Hits result = searcher.search(query);
+    ScoreDoc[] result = searcher.search(query, null, 1000).scoreDocs;
 
-    assertEquals(1, result.length());
-    Document document = result.doc(0);
+    assertEquals(1, result.length);
+    Document document = searcher.doc(result[0].doc);
     assertTrue("document is null and it shouldn't be", document != null);
     assertEquals("test text", document.get("test"));
     assertTrue("document.getFields() Size: " + document.getFields().size() + " is not: " + 2, document.getFields().size() == 2);
@@ -114,23 +114,23 @@
     // try to search the published index
     Searchable[] searchables = { getRemote() };
     Searcher searcher = new MultiSearcher(searchables);
-    Hits hits = searcher.search(
+    ScoreDoc[] hits = searcher.search(
           new TermQuery(new Term("test", "text")),
-          new QueryWrapperFilter(new TermQuery(new Term("test", "test"))));
-    assertEquals(1, hits.length());
-    Hits nohits = searcher.search(
+          new QueryWrapperFilter(new TermQuery(new Term("test", "test"))), 1000).scoreDocs;
+    assertEquals(1, hits.length);
+    ScoreDoc[] nohits = searcher.search(
           new TermQuery(new Term("test", "text")),
-          new QueryWrapperFilter(new TermQuery(new Term("test", "non-existent-term"))));
-    assertEquals(0, nohits.length());
+          new QueryWrapperFilter(new TermQuery(new Term("test", "non-existent-term"))), 1000).scoreDocs;
+    assertEquals(0, nohits.length);
   }
 
   public void testConstantScoreQuery() throws Exception {
     // try to search the published index
     Searchable[] searchables = { getRemote() };
     Searcher searcher = new MultiSearcher(searchables);
-    Hits hits = searcher.search(
+    ScoreDoc[] hits = searcher.search(
           new ConstantScoreQuery(new QueryWrapperFilter(
-                                   new TermQuery(new Term("test", "test")))));
-    assertEquals(1, hits.length());
+                                   new TermQuery(new Term("test", "test")))), null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
   }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSearchHitsWithDeletions.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSearchHitsWithDeletions.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSearchHitsWithDeletions.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSearchHitsWithDeletions.java Fri May 23 11:57:55 2008
@@ -37,6 +37,7 @@
  * Test Hits searches with interleaved deletions.
  * 
  * See {@link http://issues.apache.org/jira/browse/LUCENE-1096}.
+ * @deprecated Hits will be removed in Lucene 3.0
  */
 public class TestSearchHitsWithDeletions extends TestCase {
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java Fri May 23 11:57:55 2008
@@ -459,9 +459,9 @@
 	public void testNormalizedScores() throws Exception {
 
 		// capture relevancy scores
-		HashMap scoresX = getScores (full.search (queryX));
-		HashMap scoresY = getScores (full.search (queryY));
-		HashMap scoresA = getScores (full.search (queryA));
+    HashMap scoresX = getScores (full.search (queryX, null, 1000).scoreDocs, full);
+    HashMap scoresY = getScores (full.search (queryY, null, 1000).scoreDocs, full);
+    HashMap scoresA = getScores (full.search (queryA, null, 1000).scoreDocs, full);
 
 		// we'll test searching locally, remote and multi
 		MultiSearcher remote = new MultiSearcher (new Searchable[] { getRemote() });
@@ -470,92 +470,92 @@
 		// change sorting and make sure relevancy stays the same
 
 		sort = new Sort();
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 		sort.setSort(SortField.FIELD_DOC);
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 		sort.setSort ("int");
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 		sort.setSort ("float");
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 		sort.setSort ("string");
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 		sort.setSort (new String[] {"int","float"});
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 		sort.setSort (new SortField[] { new SortField ("int", true), new SortField (null, SortField.DOC, true) });
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 		sort.setSort (new String[] {"float","string"});
-		assertSameValues (scoresX, getScores(full.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(remote.search(queryX,sort)));
-		assertSameValues (scoresX, getScores(multi.search(queryX,sort)));
-		assertSameValues (scoresY, getScores(full.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(remote.search(queryY,sort)));
-		assertSameValues (scoresY, getScores(multi.search(queryY,sort)));
-		assertSameValues (scoresA, getScores(full.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(remote.search(queryA,sort)));
-		assertSameValues (scoresA, getScores(multi.search(queryA,sort)));
+    assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresY, getScores (multi.search (queryY, null, 1000, sort).scoreDocs, multi));
+    assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
+    assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
+    assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
 	}
 
@@ -648,11 +648,11 @@
 	// make sure the documents returned by the search match the expected list
 	private void assertMatches (Searcher searcher, Query query, Sort sort, String expectedResult)
 	throws IOException {
-		Hits result = searcher.search (query, sort);
+    ScoreDoc[] result = searcher.search (query, null, 1000, sort).scoreDocs;
 		StringBuffer buff = new StringBuffer(10);
-		int n = result.length();
+    int n = result.length;
 		for (int i=0; i<n; ++i) {
-			Document doc = result.doc(i);
+      Document doc = searcher.doc(result[i].doc);
 			String[] v = doc.getValues("tracer");
 			for (int j=0; j<v.length; ++j) {
 				buff.append (v[j]);
@@ -664,11 +664,11 @@
 	// make sure the documents returned by the search match the expected list pattern
 	private void assertMatchesPattern (Searcher searcher, Query query, Sort sort, String pattern)
 	throws IOException {
-		Hits result = searcher.search (query, sort);
+    ScoreDoc[] result = searcher.search (query, null, 1000, sort).scoreDocs;
 		StringBuffer buff = new StringBuffer(10);
-		int n = result.length();
+    int n = result.length;
 		for (int i=0; i<n; ++i) {
-			Document doc = result.doc(i);
+      Document doc = searcher.doc(result[i].doc);
 			String[] v = doc.getValues("tracer");
 			for (int j=0; j<v.length; ++j) {
 				buff.append (v[j]);
@@ -678,15 +678,15 @@
 		assertTrue (Pattern.compile(pattern).matcher(buff.toString()).matches());
 	}
 
-	private HashMap getScores (Hits hits)
+  private HashMap getScores (ScoreDoc[] hits, Searcher searcher)
 	throws IOException {
 		HashMap scoreMap = new HashMap();
-		int n = hits.length();
+    int n = hits.length;
 		for (int i=0; i<n; ++i) {
-			Document doc = hits.doc(i);
+      Document doc = searcher.doc(hits[i].doc);
 			String[] v = doc.getValues("tracer");
 			assertEquals (v.length, 1);
-			scoreMap.put (v[0], new Float(hits.score(i)));
+      scoreMap.put (v[0], new Float(hits[i].score));
 		}
 		return scoreMap;
 	}

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTermVectors.java Fri May 23 11:57:55 2008
@@ -77,12 +77,12 @@
   public void testTermVectors() {
     Query query = new TermQuery(new Term("field", "seventy"));
     try {
-      Hits hits = searcher.search(query);
-      assertEquals(100, hits.length());
+      ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+      assertEquals(100, hits.length);
       
-      for (int i = 0; i < hits.length(); i++)
+      for (int i = 0; i < hits.length; i++)
       {
-        TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits.id(i));
+        TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits[i].doc);
         assertTrue(vector != null);
         assertTrue(vector.length == 1);
       }
@@ -125,19 +125,19 @@
   public void testTermPositionVectors() {
     Query query = new TermQuery(new Term("field", "zero"));
     try {
-      Hits hits = searcher.search(query);
-      assertEquals(1, hits.length());
+      ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+      assertEquals(1, hits.length);
       
-      for (int i = 0; i < hits.length(); i++)
+      for (int i = 0; i < hits.length; i++)
       {
-        TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits.id(i));
+        TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits[i].doc);
         assertTrue(vector != null);
         assertTrue(vector.length == 1);
         
-        boolean shouldBePosVector = (hits.id(i) % 2 == 0) ? true : false;
+        boolean shouldBePosVector = (hits[i].doc % 2 == 0) ? true : false;
         assertTrue((shouldBePosVector == false) || (shouldBePosVector == true && (vector[0] instanceof TermPositionVector == true)));
        
-        boolean shouldBeOffVector = (hits.id(i) % 3 == 0) ? true : false;
+        boolean shouldBeOffVector = (hits[i].doc % 3 == 0) ? true : false;
         assertTrue((shouldBeOffVector == false) || (shouldBeOffVector == true && (vector[0] instanceof TermPositionVector == true)));
         
         if(shouldBePosVector || shouldBeOffVector){
@@ -186,12 +186,12 @@
   public void testTermOffsetVectors() {
     Query query = new TermQuery(new Term("field", "fifty"));
     try {
-      Hits hits = searcher.search(query);
-      assertEquals(100, hits.length());
+      ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+      assertEquals(100, hits.length);
       
-      for (int i = 0; i < hits.length(); i++)
+      for (int i = 0; i < hits.length; i++)
       {
-        TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits.id(i));
+        TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits[i].doc);
         assertTrue(vector != null);
         assertTrue(vector.length == 1);
         
@@ -279,20 +279,20 @@
         //System.out.println("--------");
       }
       Query query = new TermQuery(new Term("field", "chocolate"));
-      Hits hits = knownSearcher.search(query);
+      ScoreDoc[] hits = knownSearcher.search(query, null, 1000).scoreDocs;
       //doc 3 should be the first hit b/c it is the shortest match
-      assertTrue(hits.length() == 3);
-      float score = hits.score(0);
+      assertTrue(hits.length == 3);
+      float score = hits[0].score;
       /*System.out.println("Hit 0: " + hits.id(0) + " Score: " + hits.score(0) + " String: " + hits.doc(0).toString());
       System.out.println("Explain: " + knownSearcher.explain(query, hits.id(0)));
       System.out.println("Hit 1: " + hits.id(1) + " Score: " + hits.score(1) + " String: " + hits.doc(1).toString());
       System.out.println("Explain: " + knownSearcher.explain(query, hits.id(1)));
       System.out.println("Hit 2: " + hits.id(2) + " Score: " + hits.score(2) + " String: " +  hits.doc(2).toString());
       System.out.println("Explain: " + knownSearcher.explain(query, hits.id(2)));*/
-      assertTrue(hits.id(0) == 2);
-      assertTrue(hits.id(1) == 3);
-      assertTrue(hits.id(2) == 0);
-      TermFreqVector vector = knownSearcher.reader.getTermFreqVector(hits.id(1), "field");
+      assertTrue(hits[0].doc == 2);
+      assertTrue(hits[1].doc == 3);
+      assertTrue(hits[2].doc == 0);
+      TermFreqVector vector = knownSearcher.reader.getTermFreqVector(hits[1].doc, "field");
       assertTrue(vector != null);
       //System.out.println("Vector: " + vector);
       String[] terms = vector.getTerms();
@@ -308,7 +308,7 @@
         assertTrue(freqInt.intValue() == freq);        
       }
       SortedTermVectorMapper mapper = new SortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
-      knownSearcher.reader.getTermFreqVector(hits.id(1), mapper);
+      knownSearcher.reader.getTermFreqVector(hits[1].doc, mapper);
       SortedSet vectorEntrySet = mapper.getTermVectorEntrySet();
       assertTrue("mapper.getTermVectorEntrySet() Size: " + vectorEntrySet.size() + " is not: " + 10, vectorEntrySet.size() == 10);
       TermVectorEntry last = null;
@@ -326,7 +326,7 @@
       }
 
       FieldSortedTermVectorMapper fieldMapper = new FieldSortedTermVectorMapper(new TermVectorEntryFreqSortedComparator());
-      knownSearcher.reader.getTermFreqVector(hits.id(1), fieldMapper);
+      knownSearcher.reader.getTermFreqVector(hits[1].doc, fieldMapper);
       Map map = fieldMapper.getFieldToTerms();
       assertTrue("map Size: " + map.size() + " is not: " + 2, map.size() == 2);
       vectorEntrySet = (SortedSet) map.get("field");
@@ -369,10 +369,10 @@
     searcher = new IndexSearcher(directory);
 
     Query query = new TermQuery(new Term("field", "hundred"));
-    Hits hits = searcher.search(query);
-    assertEquals(10, hits.length());
-    for (int i = 0; i < hits.length(); i++) {
-      TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits.id(i));
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(10, hits.length);
+    for (int i = 0; i < hits.length; i++) {
+      TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits[i].doc);
       assertTrue(vector != null);
       assertTrue(vector.length == 1);
     }
@@ -401,10 +401,10 @@
     searcher = new IndexSearcher(directory);
 
     Query query = new TermQuery(new Term("field", "one"));
-    Hits hits = searcher.search(query);
-    assertEquals(1, hits.length());
+    ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
+    assertEquals(1, hits.length);
 
-    TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits.id(0));
+    TermFreqVector [] vector = searcher.reader.getTermFreqVectors(hits[0].doc);
     assertTrue(vector != null);
     assertTrue(vector.length == 1);
     TermPositionVector tfv = (TermPositionVector) vector[0];

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitedCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitedCollector.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitedCollector.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestTimeLimitedCollector.java Fri May 23 11:57:55 2008
@@ -86,7 +86,7 @@
     query = queryParser.parse(qtxt);
     
     // warm the searcher
-    searcher.search(query);
+    searcher.search(query, null, 1000);
 
   }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestWildcard.java Fri May 23 11:57:55 2008
@@ -153,8 +153,8 @@
 
   private void assertMatches(IndexSearcher searcher, Query q, int expectedMatches)
       throws IOException {
-    Hits result = searcher.search(q);
-    assertEquals(expectedMatches, result.length());
+    ScoreDoc[] result = searcher.search(q, null, 1000).scoreDocs;
+    assertEquals(expectedMatches, result.length);
   }
 
   /**
@@ -212,8 +212,8 @@
       String qtxt = matchAll[i];
       Query q = qp.parse(qtxt);
       if (dbg) System.out.println("matchAll: qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
-      Hits hits = searcher.search(q);
-      assertEquals(docs.length,hits.length());
+      ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
+      assertEquals(docs.length,hits.length);
     }
     
     // test queries that must find none
@@ -221,8 +221,8 @@
       String qtxt = matchNone[i];
       Query q = qp.parse(qtxt);
       if (dbg) System.out.println("matchNone: qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
-      Hits hits = searcher.search(q);
-      assertEquals(0,hits.length());
+      ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
+      assertEquals(0,hits.length);
     }
 
     // test queries that must be prefix queries and must find only one doc
@@ -232,9 +232,9 @@
         Query q = qp.parse(qtxt);
         if (dbg) System.out.println("match 1 prefix: doc="+docs[i]+" qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
         assertEquals(PrefixQuery.class, q.getClass());
-        Hits hits = searcher.search(q);
-        assertEquals(1,hits.length());
-        assertEquals(i,hits.id(0));
+        ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
+        assertEquals(1,hits.length);
+        assertEquals(i,hits[0].doc);
       }
     }
 
@@ -245,9 +245,9 @@
         Query q = qp.parse(qtxt);
         if (dbg) System.out.println("match 1 wild: doc="+docs[i]+" qtxt="+qtxt+" q="+q+" "+q.getClass().getName());
         assertEquals(WildcardQuery.class, q.getClass());
-        Hits hits = searcher.search(q);
-        assertEquals(1,hits.length());
-        assertEquals(i,hits.id(0));
+        ScoreDoc[] hits = searcher.search(q, null, 1000).scoreDocs;
+        assertEquals(1,hits.length);
+        assertEquals(i,hits[0].doc);
       }
     }
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestFieldScoreQuery.java Fri May 23 11:57:55 2008
@@ -17,11 +17,9 @@
  * limitations under the License.
  */
 
-import java.io.ObjectInputStream.GetField;
 import java.util.HashMap;
 
 import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
@@ -88,13 +86,13 @@
     Query q = new FieldScoreQuery(field,tp);
     log("test: "+q);
     QueryUtils.check(q,s);
-    Hits h = s.search(q);
-    assertEquals("All docs should be matched!",N_DOCS,h.length());
+    ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
+    assertEquals("All docs should be matched!",N_DOCS,h.length);
     String prevID = "ID"+(N_DOCS+1); // greater than all ids of docs in this test
-    for (int i=0; i<h.length(); i++) {
-      String resID = h.doc(i).get(ID_FIELD);
-      log(i+".   score="+h.score(i)+"  -  "+resID);
-      log(s.explain(q,h.id(i)));
+    for (int i=0; i<h.length; i++) {
+      String resID = s.doc(h[i].doc).get(ID_FIELD);
+      log(i+".   score="+h[i].score+"  -  "+resID);
+      log(s.explain(q,h[i].doc));
       assertTrue("res id "+resID+" should be < prev res id "+prevID, resID.compareTo(prevID)<0);
       prevID = resID;
     }
@@ -181,8 +179,8 @@
     boolean warned = false; // print warning once.
     for (int i=0; i<10; i++) {
       FieldScoreQuery q = new FieldScoreQuery(field,tp);
-      Hits h = s.search(q);
-      assertEquals("All docs should be matched!",N_DOCS,h.length());
+      ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
+      assertEquals("All docs should be matched!",N_DOCS,h.length);
       try {
         if (i==0) {
           innerArray = q.valSrc.getValues(s.getIndexReader()).getInnerArray();
@@ -203,8 +201,8 @@
     // verify new values are reloaded (not reused) for a new reader
     s = new IndexSearcher(dir);
     FieldScoreQuery q = new FieldScoreQuery(field,tp);
-    Hits h = s.search(q);
-    assertEquals("All docs should be matched!",N_DOCS,h.length());
+    ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
+    assertEquals("All docs should be matched!",N_DOCS,h.length);
     try {
       log("compare: "+innerArray+" to "+q.valSrc.getValues(s.getIndexReader()).getInnerArray());
       assertNotSame("cached field values should not be reused if reader as changed!", innerArray, q.valSrc.getValues(s.getIndexReader()).getInnerArray());

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/function/TestOrdValues.java Fri May 23 11:57:55 2008
@@ -18,7 +18,6 @@
  */
 
 import org.apache.lucene.index.CorruptIndexException;
-import org.apache.lucene.search.Hits;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.QueryUtils;
@@ -77,16 +76,16 @@
     Query q = new ValueSourceQuery(vs);
     log("test: "+q);
     QueryUtils.check(q,s);
-    Hits h = s.search(q);
-    assertEquals("All docs should be matched!",N_DOCS,h.length());
+    ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
+    assertEquals("All docs should be matched!",N_DOCS,h.length);
     String prevID = inOrder
       ? "IE"   // greater than all ids of docs in this test ("ID0001", etc.)
       : "IC";  // smaller than all ids of docs in this test ("ID0001", etc.)
           
-    for (int i=0; i<h.length(); i++) {
-      String resID = h.doc(i).get(ID_FIELD);
-      log(i+".   score="+h.score(i)+"  -  "+resID);
-      log(s.explain(q,h.id(i)));
+    for (int i=0; i<h.length; i++) {
+      String resID = s.doc(h[i].doc).get(ID_FIELD);
+      log(i+".   score="+h[i].score+"  -  "+resID);
+      log(s.explain(q,h[i].doc));
       if (inOrder) {
         assertTrue("res id "+resID+" should be < prev res id "+prevID, resID.compareTo(prevID)<0);
       } else {
@@ -159,9 +158,9 @@
         vs = new ReverseOrdFieldSource(field);
       }
       ValueSourceQuery q = new ValueSourceQuery(vs);
-      Hits h = s.search(q);
+      ScoreDoc[] h = s.search(q, null, 1000).scoreDocs;
       try {
-        assertEquals("All docs should be matched!",N_DOCS,h.length());
+        assertEquals("All docs should be matched!",N_DOCS,h.length);
         if (i==0) {
           innerArray = q.valSrc.getValues(s.getIndexReader()).getInnerArray();
         } else {
@@ -178,7 +177,7 @@
     
     ValueSource vs;
     ValueSourceQuery q;
-    Hits h;
+    ScoreDoc[] h;
     
     // verify that different values are loaded for a different field
     String field2 = INT_FIELD;
@@ -189,8 +188,8 @@
       vs = new ReverseOrdFieldSource(field2);
     }
     q = new ValueSourceQuery(vs);
-    h = s.search(q);
-    assertEquals("All docs should be matched!",N_DOCS,h.length());
+    h = s.search(q, null, 1000).scoreDocs;
+    assertEquals("All docs should be matched!",N_DOCS,h.length);
     try {
       log("compare (should differ): "+innerArray+" to "+q.valSrc.getValues(s.getIndexReader()).getInnerArray());
       assertNotSame("different values shuold be loaded for a different field!", innerArray, q.valSrc.getValues(s.getIndexReader()).getInnerArray());
@@ -209,8 +208,8 @@
       vs = new ReverseOrdFieldSource(field);
     }
     q = new ValueSourceQuery(vs);
-    h = s.search(q);
-    assertEquals("All docs should be matched!",N_DOCS,h.length());
+    h = s.search(q, null, 1000).scoreDocs;
+    assertEquals("All docs should be matched!",N_DOCS,h.length);
     try {
       log("compare (should differ): "+innerArray+" to "+q.valSrc.getValues(s.getIndexReader()).getInnerArray());
       assertNotSame("cached field values should not be reused if reader as changed!", innerArray, q.valSrc.getValues(s.getIndexReader()).getInnerArray());

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestBufferedIndexInput.java Fri May 23 11:57:55 2008
@@ -17,24 +17,24 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
 import java.io.File;
-import java.util.List;
-import java.util.Random;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.search.IndexSearcher;
+import java.util.List;
+import java.util.Random;
+
 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.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.util._TestUtil;
-
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
 
 public class TestBufferedIndexInput extends LuceneTestCase {
 	// Call readByte() repeatedly, past the buffer boundary, and see that it
@@ -184,16 +184,16 @@
         dir.tweakBufferSizes();
 
         IndexSearcher searcher = new IndexSearcher(reader);
-        Hits hits = searcher.search(new TermQuery(bbb));
+        ScoreDoc[] hits = searcher.search(new TermQuery(bbb), null, 1000).scoreDocs;
         dir.tweakBufferSizes();
-        assertEquals(35, hits.length());
+        assertEquals(35, hits.length);
         dir.tweakBufferSizes();
-        hits = searcher.search(new TermQuery(new Term("id", "33")));
+        hits = searcher.search(new TermQuery(new Term("id", "33")), null, 1000).scoreDocs;
         dir.tweakBufferSizes();
-        assertEquals(1, hits.length());
-        hits = searcher.search(new TermQuery(aaa));
+        assertEquals(1, hits.length);
+        hits = searcher.search(new TermQuery(aaa), null, 1000).scoreDocs;
         dir.tweakBufferSizes();
-        assertEquals(35, hits.length());
+        assertEquals(35, hits.length);
         searcher.close();
         reader.close();
       } finally {

Modified: lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java?rev=659626&r1=659625&r2=659626&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/store/TestLockFactory.java Fri May 23 11:57:55 2008
@@ -17,24 +17,21 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.util.LuceneTestCase;
-
-import java.util.Hashtable;
-import java.util.Enumeration;
-
-import java.io.IOException;
 import java.io.File;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Hashtable;
 
+import org.apache.lucene.analysis.WhitespaceAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
-import org.apache.lucene.index.Term;
+import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.analysis.WhitespaceAnalyzer;
+import org.apache.lucene.util.LuceneTestCase;
 
 public class TestLockFactory extends LuceneTestCase {
 
@@ -498,9 +495,9 @@
                     break;
                 }
                 if (searcher != null) {
-                    Hits hits = null;
+                    ScoreDoc[] hits = null;
                     try {
-                        hits = searcher.search(query);
+                        hits = searcher.search(query, null, 1000).scoreDocs;
                     } catch (IOException e) {
                         hitException = true;
                         System.out.println("Stress Test Index Searcher: search hit unexpected exception: " + e.toString());



Mime
View raw message