Package org.apache.lucene.search
Class MultiCollector
- java.lang.Object
-
- org.apache.lucene.search.MultiCollector
-
- All Implemented Interfaces:
Collector
public class MultiCollector extends Object implements Collector
ACollectorwhich allows running a search with severalCollectors. It offers a staticwrap(org.apache.lucene.search.Collector...)method which accepts a list of collectors and wraps them withMultiCollector, while filtering out thenullnull 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 mixingTopScoreDocCollectorandTotalHitCountCollector, it should be faster to run the query twice, once for each collector, rather than using this wrapper on a single search.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Collector[]getCollectors()Provides access to the wrappedCollectors for advanced use-casesLeafCollectorgetLeafCollector(LeafReaderContext context)Create a newcollectorto collect the given context.ScoreModescoreMode()Indicates what features are required from the scorer.voidsetWeight(Weight weight)Set theWeightthat will be used to produce scorers that will feedLeafCollectors.static Collectorwrap(Iterable<? extends Collector> collectors)Wraps a list ofCollectors with aMultiCollector.static Collectorwrap(Collector... collectors)Seewrap(Iterable).
-
-
-
Method Detail
-
wrap
public static Collector wrap(Collector... collectors)
Seewrap(Iterable).
-
wrap
public static Collector wrap(Iterable<? extends Collector> collectors)
Wraps a list ofCollectors with aMultiCollector. This method works as follows:- Filters out the
nullcollectors, 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
MultiCollectorwhich wraps the non-nullones.
- Throws:
IllegalArgumentException- if either 0 collectors were input, or all collectors arenull.
- Filters out the
-
scoreMode
public ScoreMode scoreMode()
Description copied from interface:CollectorIndicates what features are required from the scorer.
-
getLeafCollector
public LeafCollector getLeafCollector(LeafReaderContext context) throws IOException
Description copied from interface:CollectorCreate a newcollectorto collect the given context.- Specified by:
getLeafCollectorin interfaceCollector- Parameters:
context- next atomic reader context- Throws:
IOException
-
setWeight
public void setWeight(Weight weight)
Description copied from interface:CollectorSet theWeightthat will be used to produce scorers that will feedLeafCollectors. This is typically useful to have access toWeight.count(org.apache.lucene.index.LeafReaderContext)fromCollector.getLeafCollector(org.apache.lucene.index.LeafReaderContext).
-
getCollectors
public Collector[] getCollectors()
Provides access to the wrappedCollectors for advanced use-cases
-
-