Doug Cutting wrote:
When we deprecate things we should ensure:

1. That, if they're removed, everything else should keep working.

2. That they should indicate what should be used instead.

In Searchable.java we now have methods whose javadoc refers to deprecated methods, which will be a problem if those deprecated methods are removed. These deprecated search methods also do not indicate what folks should call instead.
Yes, I was sloppy here.

In each case applications should call a corresponding Searcher method.
Here I don't agree completely and have another suggestion to resolve that
issue. The affected methods are low-level API methods anyway,
and even before their javadoc referred application developers to other already
and still existing Searcher methods. If someone really needed to call one of
these methods before, IMHO he should now create a weight and call the
corresponding new method.

While checking this I also found some other references to the deprecated
methods (mainly in javadoc comments), and replaced them accordingly.
A patch proposal is attached.

--Wolf
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/RemoteSearchable.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/RemoteSearchable.java
   (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/RemoteSearchable.java
   (working copy)
@@ -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);
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/Searcher.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/Searcher.java
   (revision 164013)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/Searcher.java
   (working copy)
@@ -74,7 +74,7 @@
    */
   public void search(Query query, HitCollector results)
     throws IOException {
-    search(query, (Filter)null, results);
+    search(query.weight(this), (Filter)null, results);
   }    
 
   /** The Similarity implementation used by this searcher. */
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/TopFieldDocs.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/TopFieldDocs.java
       (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/TopFieldDocs.java
       (working copy)
@@ -25,7 +25,7 @@
  * @author  Tim Jones (Nacimiento Software)
  * @since   lucene 1.4
  * @version $Id$
- * @see Searchable#search(Query,Filter,int,Sort)
+ * @see Searchable#search(Weight,Filter,int,Sort)
  */
 public class TopFieldDocs
 extends TopDocs {
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/Searchable.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/Searchable.java
 (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/Searchable.java
 (working copy)
@@ -44,22 +44,20 @@
    * 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 [EMAIL PROTECTED] #search(Query, Filter, HitCollector)}, but 
takes
-   * a Weight instead of a query.
+   * @deprecated create a weight using [EMAIL PROTECTED] 
Query#weight(Searcher)} and
+   *             call [EMAIL PROTECTED] #search(Weight, 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 +91,14 @@
    * <p>Applications should usually call [EMAIL PROTECTED] 
Searcher#search(Query)} or
    * [EMAIL PROTECTED] 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 [EMAIL PROTECTED] #search(Query, Filter, int)}, but takes
-   * a Weight instead of a query.
+   * @deprecated create a weight using [EMAIL PROTECTED] 
Query#weight(Searcher)} and
+   *             call [EMAIL PROTECTED] #search(Weight, 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 [EMAIL PROTECTED] HitCollector} implementations.
@@ -127,7 +123,7 @@
   Explanation explain(Query query, int doc) throws IOException;
 
   /**
-   * Identical to [EMAIL PROTECTED] #search(Query, Filter, HitCollector)}, but 
takes
+   * Identical to [EMAIL PROTECTED] #explain(Query, int)}, but takes
    * a Weight instead of a query.
    */
   Explanation explain(Weight weight, int doc) throws IOException;
@@ -140,16 +136,14 @@
    * <p>Applications should usually call [EMAIL PROTECTED]
    * 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 [EMAIL PROTECTED] #search(Query, Filter, int, Sort)}, but 
takes
-   * a Weight instead of a query.
+   * @deprecated create a weight using [EMAIL PROTECTED] 
Query#weight(Searcher)} and
+   *             call [EMAIL PROTECTED] #search(Weight, 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;
 }
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/FieldDoc.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/FieldDoc.java
   (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/FieldDoc.java
   (working copy)
@@ -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 Searchable#search(Weight,Filter,int,Sort)
         */
        public Comparable[] fields;
 
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/TopDocs.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/TopDocs.java
    (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/TopDocs.java
    (working copy)
@@ -17,7 +17,7 @@
  */
 
 /** Expert: Returned by low-level search implementations.
- * @see Searcher#search(Query,Filter,int) */
+ * @see Searcher#search(Weight,Filter,int) */
 public class TopDocs implements java.io.Serializable {
   /** Expert: The total number of hits for the query.
    * @see Hits#length()
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/FieldSortedHitQueue.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/FieldSortedHitQueue.java
        (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/FieldSortedHitQueue.java
        (working copy)
@@ -35,7 +35,7 @@
  * @author  Tim Jones (Nacimiento Software)
  * @since   lucene 1.4
  * @version $Id$
- * @see Searchable#search(Query,Filter,int,Sort)
+ * @see Searchable#search(Weight,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;
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/MultiSearcher.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/MultiSearcher.java
      (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/MultiSearcher.java
      (working copy)
@@ -322,7 +322,7 @@
    *
    * @return rewritten queries
    */
-  private Weight prepareWeight(Query original) throws IOException {
+  protected Weight prepareWeight(Query original) throws IOException {
     // step 1
     Query rewrittenQuery = rewrite(original);
 
Index: 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
===================================================================
--- 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
      (revision 164009)
+++ 
D:/Programme/eclipse/workspace/lucene-svn/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
      (working copy)
@@ -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);
           }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to