Package org.apache.lucene.search
Interface Collector
-
- All Known Implementing Classes:
CachingCollector
,EarlyTerminatingSortingCollector
,FilterCollector
,MultiCollector
,MultiCollectorManager.Collectors
,PositiveScoresOnlyCollector
,SimpleCollector
,TimeLimitingCollector
,TopDocsCollector
,TopFieldCollector
,TopScoreDocCollector
,TotalHitCountCollector
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
Collector
andSimpleCollector
. Likely your application can use one of these classes, or subclassTopDocsCollector
, instead of implementing Collector directly:TopDocsCollector
is an abstract base class that assumes you will retrieve the top N docs, according to some criteria, after collection is done.TopScoreDocCollector
is a concrete subclassTopDocsCollector
and sorts according to score + docID. This is used internally by theIndexSearcher
search methods that do not take an explicitSort
. It is likely the most frequently used collector.TopFieldCollector
subclassesTopDocsCollector
and sorts according to a specifiedSort
object (sort by field). This is used internally by theIndexSearcher
search methods that take an explicitSort
.TimeLimitingCollector
, which wraps any other Collector and aborts the search if it's taken too much time.PositiveScoresOnlyCollector
wraps any other Collector and prevents collection of hits whose score is <= 0.0
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description LeafCollector
getLeafCollector(LeafReaderContext context)
Create a newcollector
to collect the given context.boolean
needsScores()
Indicates if document scores are needed by this collector.
-
-
-
Method Detail
-
getLeafCollector
LeafCollector getLeafCollector(LeafReaderContext context) throws IOException
Create a newcollector
to collect the given context.- Parameters:
context
- next atomic reader context- Throws:
IOException
-
needsScores
boolean needsScores()
Indicates if document scores are needed by this collector.- Returns:
true
if scores are needed.
-
-