Class TopGroups<T>
java.lang.Object
org.apache.lucene.search.grouping.TopGroups<T>
Represents result returned by a grouping search.
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow the GroupDocs score (if any) should be merged. -
Field Summary
FieldsModifier and TypeFieldDescriptionGroup results in groupSort orderfinal SortField[]How groups are sorted against each otherfinal floatHighest score across all hits, orFloat.NaNif scores were not computed.final IntegerThe total number of unique groups.final intNumber of documents grouped into the topN groupsfinal intNumber of documents matching the searchfinal SortField[]How docs are sorted within each group -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TopGroups<T> merge(TopGroups<T>[] shardGroups, Sort groupSort, Sort docSort, int docOffset, int docTopN, TopGroups.ScoreMergeMode scoreMergeMode) Merges an array of TopGroups, for example obtained from the second-pass collector across multiple shards.static <T> TopGroups<T> mergeBlockGroups(List<TopGroups<T>> shardGroups, Sort groupSort, int groupOffset, int topNGroups, Sort docSort) Merge TopGroups that are partitioned into blocks per shard.
-
Field Details
-
totalHitCount
public final int totalHitCountNumber of documents matching the search -
totalGroupedHitCount
public final int totalGroupedHitCountNumber of documents grouped into the topN groups -
totalGroupCount
The total number of unique groups. Ifnullthis value is not computed. -
groups
Group results in groupSort order -
groupSort
How groups are sorted against each other -
withinGroupSort
How docs are sorted within each group -
maxScore
public final float maxScoreHighest score across all hits, orFloat.NaNif scores were not computed.
-
-
Constructor Details
-
TopGroups
-
TopGroups
-
-
Method Details
-
merge
public static <T> TopGroups<T> merge(TopGroups<T>[] shardGroups, Sort groupSort, Sort docSort, int docOffset, int docTopN, TopGroups.ScoreMergeMode scoreMergeMode) Merges an array of TopGroups, for example obtained from the second-pass collector across multiple shards. Each TopGroups must have been sorted by the same groupSort and docSort, and the top groups passed to all second-pass collectors must be the same.NOTE: We can't always compute an exact totalGroupCount. Documents belonging to a group may occur on more than one shard and thus the merged totalGroupCount can be higher than the actual totalGroupCount. In this case the totalGroupCount represents a upper bound. If the documents of one group do only reside in one shard then the totalGroupCount is exact.
NOTE: the topDocs in each GroupDocs is actually an instance of TopDocsAndShards
-
mergeBlockGroups
public static <T> TopGroups<T> mergeBlockGroups(List<TopGroups<T>> shardGroups, Sort groupSort, int groupOffset, int topNGroups, Sort docSort) Merge TopGroups that are partitioned into blocks per shard. This method assumes that within each shard, the groups are sorted according to the groupSort.- Parameters:
shardGroups- list of TopGroups, one per shard.groupSort- TheSortused 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.groupOffset- Which group to start from.topNGroups- How many top groups to keep.docSort- The sort to use within each group- Returns:
- TopGroups instance or null if there are no groups.
-