Package org.apache.lucene.search
Class TopFieldCollectorManager
- java.lang.Object
-
- org.apache.lucene.search.TopFieldCollectorManager
-
- All Implemented Interfaces:
CollectorManager<TopFieldCollector,TopFieldDocs>
public class TopFieldCollectorManager extends Object implements CollectorManager<TopFieldCollector,TopFieldDocs>
Create a TopFieldCollectorManager which uses a shared hit counter to maintain number of hits and a sharedMaxScoreAccumulatorto propagate the minimum score across segments if the primary sort is by relevancy.Note that a new collectorManager should be created for each search due to its internal states.
-
-
Constructor Summary
Constructors Constructor Description TopFieldCollectorManager(Sort sort, int numHits, int totalHitsThreshold)Creates a newTopFieldCollectorManagerfrom the given arguments, with thread-safe internal states.TopFieldCollectorManager(Sort sort, int numHits, FieldDoc after, int totalHitsThreshold)Creates a newTopFieldCollectorManagerfrom the given arguments, with thread-safe internal states.TopFieldCollectorManager(Sort sort, int numHits, FieldDoc after, int totalHitsThreshold, boolean supportsConcurrency)Creates a newTopFieldCollectorManagerfrom the given arguments.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<TopFieldCollector>getCollectors()TopFieldCollectornewCollector()Return a newCollector.TopFieldDocsreduce(Collection<TopFieldCollector> collectors)Reduce the results of individual collectors into a meaningful result.
-
-
-
Constructor Detail
-
TopFieldCollectorManager
public TopFieldCollectorManager(Sort sort, int numHits, FieldDoc after, int totalHitsThreshold, boolean supportsConcurrency)
Creates a newTopFieldCollectorManagerfrom the given arguments.NOTE: The instances returned by this method pre-allocate a full array of length
numHits.- Parameters:
sort- the sort criteria (SortFields).numHits- the number of results to collect.after- the previous doc after which matching docs will be collected.totalHitsThreshold- the number of docs to count accurately. If the query matches more thantotalHitsThresholdhits then its hit count will be a lower bound. On the other hand if the query matches less than or exactlytotalHitsThresholdhits then the hit count of the result will be accurate.Integer.MAX_VALUEmay be used to make the hit count accurate, but this will also make query processing slower.supportsConcurrency- to use thread-safe and slower internal states for count tracking.
-
TopFieldCollectorManager
public TopFieldCollectorManager(Sort sort, int numHits, FieldDoc after, int totalHitsThreshold)
Creates a newTopFieldCollectorManagerfrom the given arguments, with thread-safe internal states.NOTE: The instances returned by this method pre-allocate a full array of length
numHits.- Parameters:
sort- the sort criteria (SortFields).numHits- the number of results to collect.after- the previous doc after which matching docs will be collected.totalHitsThreshold- the number of docs to count accurately. If the query matches more thantotalHitsThresholdhits then its hit count will be a lower bound. On the other hand if the query matches less than or exactlytotalHitsThresholdhits then the hit count of the result will be accurate.Integer.MAX_VALUEmay be used to make the hit count accurate, but this will also make query processing slower.
-
TopFieldCollectorManager
public TopFieldCollectorManager(Sort sort, int numHits, int totalHitsThreshold)
Creates a newTopFieldCollectorManagerfrom the given arguments, with thread-safe internal states.NOTE: The instances returned by this method pre-allocate a full array of length
numHits.- Parameters:
sort- the sort criteria (SortFields).numHits- the number of results to collect.totalHitsThreshold- the number of docs to count accurately. If the query matches more thantotalHitsThresholdhits then its hit count will be a lower bound. On the other hand if the query matches less than or exactlytotalHitsThresholdhits then the hit count of the result will be accurate.Integer.MAX_VALUEmay be used to make the hit count accurate, but this will also make query processing slower.
-
-
Method Detail
-
newCollector
public TopFieldCollector newCollector()
Description copied from interface:CollectorManagerReturn a newCollector. This must return a different instance on each call.- Specified by:
newCollectorin interfaceCollectorManager<TopFieldCollector,TopFieldDocs>
-
reduce
public TopFieldDocs reduce(Collection<TopFieldCollector> collectors) throws IOException
Description copied from interface:CollectorManagerReduce the results of individual collectors into a meaningful result. For instance aTopDocsCollectorwould compute thetop docsof each collector and then merge them usingTopDocs.merge(int, TopDocs[]). This method must be called after collection is finished on all provided collectors.- Specified by:
reducein interfaceCollectorManager<TopFieldCollector,TopFieldDocs>- Throws:
IOException
-
getCollectors
public List<TopFieldCollector> getCollectors()
-
-