Package org.apache.lucene.search
Class MultiCollector
java.lang.Object
org.apache.lucene.search.MultiCollector
- All Implemented Interfaces:
Collector
A
Collector
which allows running a search with several Collector
s. It offers a
static wrap(org.apache.lucene.search.Collector...)
method which accepts a list of collectors and wraps them with MultiCollector
, while filtering out the null
null ones.
NOTE:When mixing collectors that want to skip low-scoring hits (ScoreMode.TOP_SCORES
) with ones that require to see all hits, such as mixing TopScoreDocCollector
and TotalHitCountCollector
, it should be faster to run the query
twice, once for each collector, rather than using this wrapper on a single search.
-
Method Summary
Modifier and TypeMethodDescriptionProvides access to the wrappedCollector
s for advanced use-casesgetLeafCollector
(LeafReaderContext context) Create a newcollector
to collect the given context.Indicates what features are required from the scorer.static Collector
Wraps a list ofCollector
s with aMultiCollector
.static Collector
Seewrap(Iterable)
.
-
Method Details
-
wrap
Seewrap(Iterable)
. -
wrap
Wraps a list ofCollector
s with aMultiCollector
. This method works as follows:- Filters out the
null
collectors, so they are not used during search time. - If the input contains 1 real collector (i.e. non-
null
), it is returned. - Otherwise the method returns a
MultiCollector
which wraps the non-null
ones.
- Throws:
IllegalArgumentException
- if either 0 collectors were input, or all collectors arenull
.
- Filters out the
-
scoreMode
Description copied from interface:Collector
Indicates what features are required from the scorer. -
getLeafCollector
Description copied from interface:Collector
Create a newcollector
to collect the given context.- Specified by:
getLeafCollector
in interfaceCollector
- Parameters:
context
- next atomic reader context- Throws:
IOException
-
getCollectors
Provides access to the wrappedCollector
s for advanced use-cases
-