public class BlockGroupingCollector extends SimpleCollector
This results in faster performance (~25% faster QPS)
than the two-pass grouping collectors, with the tradeoff
being that the documents in each group must always be
indexed as a block. This collector also fills in
TopGroups.totalGroupCount without requiring the separate
TermAllGroupsCollector. However, this collector does
not fill in the groupValue of each group; this field
will always be null.
NOTE: this collector makes no effort to verify the docs were in fact indexed as a block, so it's up to you to ensure this was the case.
org.apache.lucene.search.grouping for more
details including a full code example.
|Constructor and Description|
Create the single pass collector.
|Modifier and Type||Method and Description|
Returns the grouped results.
public BlockGroupingCollector(Sort groupSort, int topNGroups, boolean needsScores, Filter lastDocPerGroup) throws IOException
Sortused to sort the groups. The top sorted document within each group according to groupSort, determines how that group sorts against other groups. This must be non-null, ie, if you want to groupSort by relevance use Sort.RELEVANCE.
topNGroups- How many top groups to keep.
needsScores- true if the collected documents require scores, either because relevance is included in the withinGroupSort or because you plan to pass true for either getSscores or getMaxScores to
getTopGroups(org.apache.lucene.search.Sort, int, int, int, boolean)
Filterthat marks the last document in each group.
public TopGroups<?> getTopGroups(Sort withinGroupSort, int groupOffset, int withinGroupOffset, int maxDocsPerGroup, boolean fillSortFields) throws IOException
NOTE: This collector is unable to compute the groupValue per group so it will always be null. This is normally not a problem, as you can obtain the value just like you obtain other values for each matching document (eg, via stored fields, via DocValues, etc.)
Sortused to sort documents within each group. Passing null is allowed, to sort by relevance.
groupOffset- Which group to start from
withinGroupOffset- Which document to start from within each group
maxDocsPerGroup- How many top documents to keep within each group.
fillSortFields- If true then the Comparable values for the sort fields will be set
public void setScorer(Scorer scorer) throws IOException
public void collect(int doc) throws IOException
Copyright © 2000-2015 Apache Software Foundation. All Rights Reserved.