lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r164865 - in /lucene/java/trunk/src: java/org/apache/lucene/search/ test/org/apache/lucene/search/
Date Tue, 26 Apr 2005 19:30:21 GMT
Author: cutting
Date: Tue Apr 26 12:30:20 2005
New Revision: 164865

URL: http://svn.apache.org/viewcvs?rev=164865&view=rev
Log:
Improvements to patch #31841 from Wolf Siberski.  Deprecation is now consistent.  Tests now
pass.

Modified:
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldSortedHitQueue.java
    lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/java/trunk/src/java/org/apache/lucene/search/MultiSearcher.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
    lucene/java/trunk/src/java/org/apache/lucene/search/RemoteSearchable.java
    lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java
    lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocs.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldDoc.java Tue Apr 26 12:30:20
2005
@@ -46,7 +46,7 @@
 	 * Sort object.  Each Object will be either an Integer, Float or String,
 	 * depending on the type of values in the terms of the original field.
 	 * @see Sort
-	 * @see Searchable#search(Query,Filter,int,Sort)
+	 * @see Searcher#search(Query,Filter,int,Sort)
 	 */
 	public Comparable[] fields;
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldSortedHitQueue.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/FieldSortedHitQueue.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldSortedHitQueue.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldSortedHitQueue.java Tue Apr 26
12:30:20 2005
@@ -35,7 +35,7 @@
  * @author  Tim Jones (Nacimiento Software)
  * @since   lucene 1.4
  * @version $Id$
- * @see Searchable#search(Query,Filter,int,Sort)
+ * @see Searcher#search(Query,Filter,int,Sort)
  * @see FieldCache
  */
 class FieldSortedHitQueue
@@ -110,7 +110,7 @@
    * by a MultiSearcher with other search hits.
    * @param  doc  The FieldDoc to store sort values into.
    * @return  The same FieldDoc passed in.
-   * @see Searchable#search(Query,Filter,int,Sort)
+   * @see Searchable#search(Weight,Filter,int,Sort)
    */
   FieldDoc fillFields (final FieldDoc doc) {
     final int n = comparators.length;

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java Tue Apr 26 12:30:20
2005
@@ -86,12 +86,6 @@
   }
 
   // inherit javadoc
-  public TopDocs search(Query query, Filter filter, final int nDocs)
-       throws IOException {
-    return search(query.weight(this), filter, nDocs);
-  }
-
-  // inherit javadoc
   public TopDocs search(Weight weight, Filter filter, final int nDocs)
        throws IOException {
 
@@ -127,13 +121,6 @@
   }
 
   // inherit javadoc
-  public TopFieldDocs search(Query query, Filter filter, final int nDocs,
-                             Sort sort)
-    throws IOException {
-    return search(query.weight(this), filter, nDocs, sort);
-  }
-
-  // inherit javadoc
   public TopFieldDocs search(Weight weight, Filter filter, final int nDocs,
                              Sort sort)
       throws IOException {
@@ -162,13 +149,6 @@
     return new TopFieldDocs(totalHits[0], scoreDocs, hq.getFields());
   }
 
-
-  // inherit javadoc
-  public void search(Query query, Filter filter,
-                     final HitCollector results) throws IOException {
-    search(query.weight(this), filter, results);
-  }
-
   // inherit javadoc
   public void search(Weight weight, Filter filter,
                      final HitCollector results) throws IOException {
@@ -197,10 +177,6 @@
       query = rewrittenQuery;
     }
     return query;
-  }
-
-  public Explanation explain(Query query, int doc) throws IOException {
-    return explain(query.weight(this), doc);
   }
 
   public Explanation explain(Weight weight, int doc) throws IOException {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/MultiSearcher.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/MultiSearcher.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/MultiSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/MultiSearcher.java Tue Apr 26 12:30:20
2005
@@ -84,34 +84,18 @@
       throw new UnsupportedOperationException();
     }
 
-    public Explanation explain(Query query,int doc) throws IOException{
-      throw new UnsupportedOperationException();
-    }
-
     public Explanation explain(Weight weight,int doc) throws IOException {
       throw new UnsupportedOperationException();
     }
 
-    public void search(Query query, Filter filter, HitCollector results) throws IOException
{
-      throw new UnsupportedOperationException();
-    }
-
     public void search(Weight weight, Filter filter, HitCollector results) throws IOException
{
       throw new UnsupportedOperationException();
     }
 
-    public TopDocs search(Query query,Filter filter,int n) throws IOException {
-      throw new UnsupportedOperationException();
-    }
-
     public TopDocs search(Weight weight,Filter filter,int n) throws IOException {
       throw new UnsupportedOperationException();
     }
 
-    public TopFieldDocs search(Query query,Filter filter,int n,Sort sort) throws IOException
{
-      throw new UnsupportedOperationException();
-    }
-
     public TopFieldDocs search(Weight weight,Filter filter,int n,Sort sort) throws IOException
{
       throw new UnsupportedOperationException();
     }
@@ -203,12 +187,6 @@
     return maxDoc;
   }
 
-  public TopDocs search(Query query, Filter filter, int nDocs)
-      throws IOException {
-    Weight weight = prepareWeight(query);
-    return search(weight, filter, nDocs);
-  }
-
   public TopDocs search(Weight weight, Filter filter, int nDocs)
   throws IOException {
 
@@ -234,13 +212,6 @@
     return new TopDocs(totalHits, scoreDocs);
   }
 
-
-  public TopFieldDocs search (Query query, Filter filter, int n, Sort sort)
-    throws IOException {
-    Weight weight = prepareWeight(query);
-    return search(weight, filter, n, sort);
-  }
-
   public TopFieldDocs search (Weight weight, Filter filter, int n, Sort sort)
   throws IOException {
     FieldDocSortedHitQueue hq = null;
@@ -268,13 +239,6 @@
 
 
   // inherit javadoc
-  public void search(Query query, Filter filter, final HitCollector results)
-    throws IOException {
-      Weight weight = prepareWeight(query);
-      search(weight, filter, results);
-  }
-
-  // inherit javadoc
   public void search(Weight weight, Filter filter, final HitCollector results)
     throws IOException {
     for (int i = 0; i < searchables.length; i++) {
@@ -298,12 +262,6 @@
     return queries[0].combine(queries);
   }
 
-  public Explanation explain(Query query, int doc) throws IOException {
-    Weight weight = prepareWeight(query);
-    return explain(weight, doc);
-  }
-
-
   public Explanation explain(Weight weight, int doc) throws IOException {
     int i = subSearcher(doc);			  // find searcher index
     return searchables[i].explain(weight,doc-starts[i]); // dispatch to searcher
@@ -322,7 +280,7 @@
    *
    * @return rewritten queries
    */
-  private Weight prepareWeight(Query original) throws IOException {
+  protected Weight createWeight(Query original) throws IOException {
     // step 1
     Query rewrittenQuery = rewrite(original);
 

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java Tue Apr
26 12:30:20 2005
@@ -158,13 +158,13 @@
    * 
    * TODO: parallelize this one too
    */
-  public void search(Query query, Filter filter, final HitCollector results)
+  public void search(Weight weight, Filter filter, final HitCollector results)
     throws IOException {
     for (int i = 0; i < searchables.length; i++) {
 
       final int start = starts[i];
 
-      searchables[i].search(query, filter, new HitCollector() {
+      searchables[i].search(weight, filter, new HitCollector() {
           public void collect(int doc, float score) {
             results.collect(doc + start, score);
           }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/RemoteSearchable.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/RemoteSearchable.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/RemoteSearchable.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/RemoteSearchable.java Tue Apr 26 12:30:20
2005
@@ -39,6 +39,8 @@
     this.local = local;
   }
   
+  // this implementation should be removed when the deprecated
+  // Searchable#search(Query,Filter,HitCollector) is removed
   public void search(Query query, Filter filter, HitCollector results)
     throws IOException {
     local.search(query, filter, results);
@@ -66,6 +68,8 @@
     return local.maxDoc();
   }
 
+  // this implementation should be removed when the deprecated
+  // Searchable#search(Query,Filter,int) is removed
   public TopDocs search(Query query, Filter filter, int n) throws IOException {
     return local.search(query, filter, n);
   }
@@ -74,6 +78,8 @@
     return local.search(weight, filter, n);
   }
 
+  // this implementation should be removed when the deprecated
+  // Searchable#search(Query,Filter,int,Sort) is removed
   public TopFieldDocs search (Query query, Filter filter, int n, Sort sort)
     throws IOException {
     return local.search (query, filter, n, sort);
@@ -92,6 +98,8 @@
     return local.rewrite(original);
   }
 
+  // this implementation should be removed when the deprecated
+  // Searchable#explain(Query,int) is removed
   public Explanation explain(Query query, int doc) throws IOException {
     return local.explain(query, doc);
   }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Searchable.java Tue Apr 26 12:30:20
2005
@@ -44,22 +44,19 @@
    * Searcher#search(Query)}) is usually more efficient, as it skips
    * non-high-scoring hits.
    *
-   * @param query to match documents
+   * @param weight to match documents
    * @param filter if non-null, a bitset used to eliminate some documents
    * @param results to receive hits
    * @throws BooleanQuery.TooManyClauses
-   *
-   * @deprecated
    */
-  void search(Query query, Filter filter, HitCollector results)
-    throws IOException;
+  void search(Weight weight, Filter filter, HitCollector results)
+  throws IOException;
 
   /** Expert: Low-level search implementation.
-   * Identical to {@link #search(Query, Filter, HitCollector)}, but takes
-   * a Weight instead of a query.
+   * @deprecated use {@link Searcher#search(Query, Filter, HitCollector)} instead.
    */
-  void search(Weight weight, Filter filter, HitCollector results)
-  throws IOException;
+  void search(Query query, Filter filter, HitCollector results)
+    throws IOException;
 
   /** Frees resources associated with this Searcher.
    * Be careful not to call this method while you are still using objects
@@ -93,16 +90,13 @@
    * <p>Applications should usually call {@link Searcher#search(Query)} or
    * {@link Searcher#search(Query,Filter)} instead.
    * @throws BooleanQuery.TooManyClauses
-   *
-   * @deprecated
    */
-  TopDocs search(Query query, Filter filter, int n) throws IOException;
+  TopDocs search(Weight weight, Filter filter, int n) throws IOException;
 
   /** Expert: Low-level search implementation.
-   * Identical to {@link #search(Query, Filter, int)}, but takes
-   * a Weight instead of a query.
+   * @deprecated use {@link Searcher#search(Query, Filter, int)} instead.
    */
-  TopDocs search(Weight weight, Filter filter, int n) throws IOException;
+  TopDocs search(Query query, Filter filter, int n) throws IOException;
 
   /** Expert: Returns the stored fields of document <code>i</code>.
    * Called by {@link HitCollector} implementations.
@@ -115,22 +109,23 @@
    */
   Query rewrite(Query query) throws IOException;
 
-  /** Returns an Explanation that describes how <code>doc</code> scored against
-   * <code>query</code>.
+  /** Expert: low-level implementation method
+   * Returns an Explanation that describes how <code>doc</code> scored against
+   * <code>weight</code>.
    *
    * <p>This is intended to be used in developing Similarity implementations,
    * and, for good performance, should not be displayed with every hit.
    * Computing an explanation is as expensive as executing the query over the
    * entire index.
+   * <p>Applications should call {@link Searcher#explain(Query, int)}.
    * @throws BooleanQuery.TooManyClauses
    */
-  Explanation explain(Query query, int doc) throws IOException;
+  Explanation explain(Weight weight, int doc) throws IOException;
 
   /**
-   * Identical to {@link #search(Query, Filter, HitCollector)}, but takes
-   * a Weight instead of a query.
+   * @deprecated use {@link Searcher#explain(Query, int)} instead.
    */
-  Explanation explain(Weight weight, int doc) throws IOException;
+  Explanation explain(Query query, int doc) throws IOException;
 
   /** Expert: Low-level search implementation with arbitrary sorting.  Finds
    * the top <code>n</code> hits for <code>query</code>, applying
@@ -140,16 +135,13 @@
    * <p>Applications should usually call {@link
    * Searcher#search(Query,Filter,Sort)} instead.
    * @throws BooleanQuery.TooManyClauses
-   *
-   * @deprecated
    */
-  TopFieldDocs search(Query query, Filter filter, int n, Sort sort)
-    throws IOException;
+  TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
+  throws IOException;
 
   /** Expert: Low-level search implementation.
-   * Identical to {@link #search(Query, Filter, int, Sort)}, but takes
-   * a Weight instead of a query.
+   * @deprecated use {@link Searcher#search(Query, Filter, int, Sort)} instead.
    */
-  TopFieldDocs search(Weight weight, Filter filter, int n, Sort sort)
-  throws IOException;
+  TopFieldDocs search(Query query, Filter filter, int n, Sort sort)
+    throws IOException;
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Searcher.java Tue Apr 26 12:30:20
2005
@@ -58,6 +58,20 @@
     return new Hits(this, query, filter, sort);
   }
 
+  /** Expert: Low-level search implementation with arbitrary sorting.  Finds
+   * the top <code>n</code> hits for <code>query</code>, applying
+   * <code>filter</code> if non-null, and sorting the hits by the criteria in
+   * <code>sort</code>.
+   *
+   * <p>Applications should usually call {@link
+   * Searcher#search(Query,Filter,Sort)} instead.
+   * @throws BooleanQuery.TooManyClauses
+   */
+  public TopFieldDocs search(Query query, Filter filter, int n,
+                                      Sort sort) throws IOException {
+    return search(createWeight(query), filter, n, sort);
+  }
+
   /** Lower-level search API.
    *
    * <p>{@link HitCollector#collect(int,float)} is called for every non-zero
@@ -77,6 +91,53 @@
     search(query, (Filter)null, results);
   }    
 
+  /** Lower-level search API.
+   *
+   * <p>{@link HitCollector#collect(int,float)} is called for every non-zero
+   * scoring document.
+   * <br>HitCollector-based access to remote indexes is discouraged.
+   *
+   * <p>Applications should only use this if they need <i>all</i> of the
+   * matching documents.  The high-level search API ({@link
+   * Searcher#search(Query)}) is usually more efficient, as it skips
+   * non-high-scoring hits.
+   *
+   * @param query to match documents
+   * @param filter if non-null, a bitset used to eliminate some documents
+   * @param results to receive hits
+   * @throws BooleanQuery.TooManyClauses
+   */
+  public void search(Query query, Filter filter, HitCollector results)
+    throws IOException {
+    search(createWeight(query), filter, results);
+  }
+
+  /** Expert: Low-level search implementation.  Finds the top <code>n</code>
+   * hits for <code>query</code>, applying <code>filter</code> if
non-null.
+   *
+   * <p>Called by {@link Hits}.
+   *
+   * <p>Applications should usually call {@link Searcher#search(Query)} or
+   * {@link Searcher#search(Query,Filter)} instead.
+   * @throws BooleanQuery.TooManyClauses
+   */
+  public TopDocs search(Query query, Filter filter, int n)
+    throws IOException {
+    return search(createWeight(query), filter, n);
+  }
+
+  /** Returns an Explanation that describes how <code>doc</code> scored against
+   * <code>query</code>.
+   *
+   * <p>This is intended to be used in developing Similarity implementations,
+   * and, for good performance, should not be displayed with every hit.
+   * Computing an explanation is as expensive as executing the query over the
+   * entire index.
+   */
+  public Explanation explain(Query query, int doc) throws IOException {
+    return explain(createWeight(query), doc);
+  }
+
   /** The Similarity implementation used by this searcher. */
   private Similarity similarity = Similarity.getDefault();
 
@@ -96,6 +157,13 @@
     return this.similarity;
   }
 
+  /**
+   * creates a weight for <code>query</code>
+   * @return new weight
+   */
+  protected Weight createWeight(Query query) throws IOException {
+      return query.weight(this);
+  }
 
   // inherit javadoc
   public int[] docFreqs(Term[] terms) throws IOException {
@@ -105,5 +173,4 @@
     }
     return result;
   }
-
 }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocs.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocs.java?rev=164865&r1=164864&r2=164865&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocs.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocs.java Tue Apr 26 12:30:20
2005
@@ -25,7 +25,7 @@
  * @author  Tim Jones (Nacimiento Software)
  * @since   lucene 1.4
  * @version $Id$
- * @see Searchable#search(Query,Filter,int,Sort)
+ * @see Searcher#search(Query,Filter,int,Sort)
  */
 public class TopFieldDocs
 extends TopDocs {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java?rev=164865&r1=164864&r2=164865&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 Tue Apr 26 12:30:20
2005
@@ -344,12 +344,8 @@
 		HashMap scoresA = getScores (full.search (queryA));
 
 		// we'll test searching locally, remote and multi
-		// note: the multi test depends on each separate index containing
-		// the same documents as our local index, so the computed normalization
-		// will be the same.  so we make a multi searcher over two equal document
-		// sets - not realistic, but necessary for testing.
 		MultiSearcher remote = new MultiSearcher (new Searchable[] { getRemote() });
-		MultiSearcher multi  = new MultiSearcher (new Searchable[] { full, full });
+		MultiSearcher multi  = new MultiSearcher (new Searchable[] { searchX, searchY });
 
 		// change sorting and make sure relevancy stays the same
 



Mime
View raw message