Class FirstPassGroupingCollectorManager<T>
java.lang.Object
org.apache.lucene.search.grouping.FirstPassGroupingCollectorManager<T>
- All Implemented Interfaces:
CollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>>
public class FirstPassGroupingCollectorManager<T>
extends Object
implements CollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>>
A CollectorManager implementation for
FirstPassGroupingCollector that supports parallel
collection and merges results across segments.
Example usage:
IndexSearcher searcher = new IndexSearcher(reader);
Sort groupSort = Sort.RELEVANCE;
int topNGroups = 10;
FirstPassGroupingCollectorManager<BytesRef> manager =
new FirstPassGroupingCollectorManager<>(
() -> new TermGroupSelector("category"),
groupSort,
0,
topNGroups);
Collection<SearchGroup<BytesRef>> searchGroups = searcher.search(query, manager);
// searchGroups can then be passed to a second pass collector manager like TopGroupsCollectorManager for full group results
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
ConstructorsConstructorDescriptionFirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups) Creates a new FirstPassGroupingCollectorManager.FirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups, boolean ignoreDocsWithoutGroupField) Creates a new FirstPassGroupingCollectorManager. -
Method Summary
-
Constructor Details
-
FirstPassGroupingCollectorManager
public FirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups) Creates a new FirstPassGroupingCollectorManager.- Parameters:
groupSelectorFactory- factory to create group selectors for each collectorgroupSort- the sort to use for groupsgroupOffset- The offset in the collected groupstopNGroups- the number of top groups to collect
-
FirstPassGroupingCollectorManager
public FirstPassGroupingCollectorManager(Supplier<GroupSelector<T>> groupSelectorFactory, Sort groupSort, int groupOffset, int topNGroups, boolean ignoreDocsWithoutGroupField) Creates a new FirstPassGroupingCollectorManager.- Parameters:
groupSelectorFactory- factory to create group selectors for each collectorgroupSort- the sort to use for groupsgroupOffset- The offset in the collected groupstopNGroups- the number of top groups to collectignoreDocsWithoutGroupField- whether to ignore documents without a group field
-
-
Method Details
-
newCollector
- Specified by:
newCollectorin interfaceCollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>> - Throws:
IOException
-
reduce
public Collection<SearchGroup<T>> reduce(Collection<FirstPassGroupingCollector<T>> collectors) throws IOException - Specified by:
reducein interfaceCollectorManager<FirstPassGroupingCollector<T>,Collection<SearchGroup<T>>> - Throws:
IOException
-