Class BlockGroupingCollectorManager<T>
- All Implemented Interfaces:
CollectorManager<BlockGroupingCollector,TopGroups<T>>
CollectorManager for BlockGroupingCollector that merges results from multiple
collectors into a single TopGroups. This is intended for use with concurrent search,
where each slice is searched by a separate BlockGroupingCollector.
Documents must be indexed as blocks using IndexWriter.addDocuments() or IndexWriter.updateDocuments().
NOTE: All documents in a group block must be processed by the same BlockGroupingCollector instance. This means that the IndexSearcher's slices must not split a segment in a way that places
documents from the same block into different slices. The default IndexSearcher.slices(java.util.List<org.apache.lucene.index.LeafReaderContext>) implementation (inter-segment only) satisfies this
constraint. If intra-segment concurrency is desired, the caller must override IndexSearcher.slices(java.util.List<org.apache.lucene.index.LeafReaderContext>) to ensure each doc block falls entirely within one
slice.
See BlockGroupingCollector for more details.
Example usage:
IndexSearcher searcher = ...; // your IndexSearcher
Query lastDocPerGroupQuery = new TermQuery(new Term("groupEnd", "true"));
Weight lastDocPerGroup = searcher.createWeight(
searcher.rewrite(lastDocPerGroupQuery), ScoreMode.COMPLETE_NO_SCORES, 1);
BlockGroupingCollectorManager<BytesRef> manager = new BlockGroupingCollectorManager<>(
Sort.RELEVANCE, // groupSort
0, // groupOffset
10, // topNGroups
true, // needsScores
lastDocPerGroup,
Sort.RELEVANCE, // withinGroupSort
0, // withinGroupOffset
5); // maxDocsPerGroup
TopGroups<BytesRef> result = searcher.search(query, manager);
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Constructor Summary
ConstructorsConstructorDescriptionBlockGroupingCollectorManager(Sort groupSort, int groupOffset, int topNGroups, boolean needsScores, Weight lastDocPerGroup, Sort withinGroupSort, int withinGroupOffset, int maxDocsPerGroup) Creates a new BlockGroupingCollectorManager. -
Method Summary
-
Constructor Details
-
BlockGroupingCollectorManager
public BlockGroupingCollectorManager(Sort groupSort, int groupOffset, int topNGroups, boolean needsScores, Weight lastDocPerGroup, Sort withinGroupSort, int withinGroupOffset, int maxDocsPerGroup) Creates a new BlockGroupingCollectorManager.- Parameters:
groupSort- the sort used to rank groupsgroupOffset- the offset into the groups to start returning fromtopNGroups- the number of top groups to collectneedsScores- whether scores are needed (must be true if groupSort or withinGroupSort uses scores)lastDocPerGroup- aWeightthat matches the last document in each group blockwithinGroupSort- the sort used to rank documents within each groupwithinGroupOffset- the offset into each group's documents to start returning frommaxDocsPerGroup- the maximum number of documents to return per group
-
-
Method Details
-
newCollector
- Specified by:
newCollectorin interfaceCollectorManager<BlockGroupingCollector,TopGroups<T>> - Throws:
IOException
-
reduce
- Specified by:
reducein interfaceCollectorManager<BlockGroupingCollector,TopGroups<T>> - Throws:
IOException
-