public interface Collector
Expert: Collectors are primarily meant to be used to gather raw results from a search, and implement sorting or custom result filtering, collation, etc.
Lucene's core collectors are derived from
SimpleCollector. Likely your application can
use one of these classes, or subclass
instead of implementing Collector directly:
TopDocsCollectoris an abstract base class that assumes you will retrieve the top N docs, according to some criteria, after collection is done.
TopScoreDocCollectoris a concrete subclass
TopDocsCollectorand sorts according to score + docID. This is used internally by the
IndexSearchersearch methods that do not take an explicit
Sort. It is likely the most frequently used collector.
TopDocsCollectorand sorts according to a specified
Sortobject (sort by field). This is used internally by the
IndexSearchersearch methods that take an explicit
TimeLimitingCollector, which wraps any other Collector and aborts the search if it's taken too much time.
PositiveScoresOnlyCollectorwraps any other Collector and prevents collection of hits whose score is <= 0.0
LeafCollector getLeafCollector(LeafReaderContext context) throws IOException
collectorto collect the given context.
context- next atomic reader context
trueif scores are needed.