Artem, The four methods on the Collector abstract class are invoked by the searcher that is performing the search, and are up to you to implement in your collector as is necessary.
With the change to segment-by-segment searching in 2.9, SetScorer and SetNextReader allow the searcher to pass the current Scorer and IndexReader to the collector. The javadocs have the same content as the .NET documentation comments, and the one for Collector is: http://lucene.apache.org/java/2_9_2/api/all/org/apache/lucene/search/Col lector.html Additionally, take a look at the Test project file Search\QueryUtils.cs - there are two Collector implementations in it - AnonymousClassCollector & AnonymousClassCollector1 that are good examples of how to implement a concrete Collector. Michael -----Original Message----- From: Artem Chereisky [mailto:[email protected]] Sent: Sunday, March 07, 2010 8:27 PM To: [email protected] Subject: new 2.9 search API Hi, I'm migrating my code to 2.9 and I'm having trouble understanding the new search API Here is a sample 2.4 code: var searcher = new IndexSearcher(someReader); searcher.SetSimilarity(new MySimilarity()); var hitCollector = new MyHitCollector(); var query = MyBuildQueryMethod(); searcher.Search(query, hitCollector); The Collect method of MyHitCollector gets called for every matching document with a docId and a score based on MySimilarity implementation. In 2.9 HitCollector is replaced with Collector with 4 abstract methods to implement. One of them is SetScorer(Scorer). This is where I'm getting lost. Where do I get an instance of scorer from? There are many, one for each query type. I think I'm missing something fundamental. Please clarify. Regards, Art
