Writing a Collector is the correct and fastest way to do this. The Javadoc
pointing to deprec API is incorrect.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de

  _____  

From: DM Smith [mailto:dmsmith...@gmail.com] 
Sent: Sunday, October 04, 2009 12:04 AM
To: java-dev@lucene.apache.org
Subject: Searcher javadoc problem

 

I'm working on migrating my code to 2.9. And I'm trying to figure out what
to do. Along the way I found a circular argument in the JavaDoc for
Searcher. BTW, this is not a user question.

 

My current code calls:

                Hits hits = searcher.search(query);

 

The JavaDoc for it says:

  /** Returns the documents matching <code>query</code>. 

   * @throws BooleanQuery.TooManyClauses

   * @deprecated Hits will be removed in Lucene 3.0. Use

   * {...@link #search(Query, Filter, int)} instead.

   */

  public final Hits search(Query query) throws IOException {

    return search(query, (Filter)null);

  }

 

However, search(Query, Filter, int) is not quite appropriate as I need all
hits. I guess I could pass null for filter and MAX_INT.

 

So, I found search(Query, Collector), which seems most appropriate. (Not
sure though, but I'll figure it out.) However, the JavaDoc for it says:

  /** Lower-level search API.

  *

  * <p>{...@link Collector#collect(int)} is called for every matching document.

  *

  * <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.

  * <p>Note: The <code>score</code> passed to this method is a raw score.

  * In other words, the score will not necessarily be a float whose value is

  * between 0 and 1.

  * @throws BooleanQuery.TooManyClauses

  */

 public void search(Query query, Collector results)

   throws IOException {

   search(createWeight(query), null, results);

 }

 

But Searcher.search(Query) is deprecated.

 

So what is the appropriate documentation for getting all "hits"? Seems to
say, "Don't do that"

 

-- DM

 

 

Reply via email to