Class BlockGroupingCollector
BlockGroupingCollector performs grouping with a single pass collector, as long as you are grouping by a doc block field, ie all documents sharing a given group value were indexed as a doc block using the atomic AddDocuments(IEnumerable<IEnumerable<IIndexableField>>, Analyzer) or UpdateDocuments(Term, IEnumerable<IEnumerable<IIndexableField>>, Analyzer) API.
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.
See org.apache.lucene.search.grouping for more details including a full code example.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Search.Grouping
Assembly: Lucene.Net.Grouping.dll
Syntax
public class BlockGroupingCollector : ICollector
Constructors
| Improve this Doc View SourceBlockGroupingCollector(Sort, Int32, Boolean, Filter)
Create the single pass collector.
Declaration
public BlockGroupingCollector(Sort groupSort, int topNGroups, bool needsScores, Filter lastDocPerGroup)
Parameters
Type | Name | Description |
---|---|---|
Sort | groupSort | The Sort used 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 RELEVANCE. |
System.Int32 | topNGroups | How many top groups to keep. |
System.Boolean | 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 GetScores or GetMaxScores to GetTopGroups(Sort, Int32, Int32, Int32, Boolean) |
Filter | lastDocPerGroup | a Filter that marks the last document in each group. |
Properties
| Improve this Doc View SourceAcceptsDocsOutOfOrder
Declaration
public virtual bool AcceptsDocsOutOfOrder { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceCollect(Int32)
Declaration
public virtual void Collect(int doc)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | doc |
GetTopGroups(Sort, Int32, Int32, Int32, Boolean)
Returns the grouped results. Returns null if the number of groups collected is <= groupOffset.
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 FieldCache, etc.)
Declaration
public virtual ITopGroups<object> GetTopGroups(Sort withinGroupSort, int groupOffset, int withinGroupOffset, int maxDocsPerGroup, bool fillSortFields)
Parameters
Type | Name | Description |
---|---|---|
Sort | withinGroupSort | The Sort used to sort documents within each group. Passing null is allowed, to sort by relevance. |
System.Int32 | groupOffset | Which group to start from |
System.Int32 | withinGroupOffset | Which document to start from within each group |
System.Int32 | maxDocsPerGroup | How many top documents to keep within each group. |
System.Boolean | fillSortFields | If true then the Comparable values for the sort fields will be set |
Returns
Type | Description |
---|---|
ITopGroups<System.Object> |
GetTopGroups<TGroupValue>(Sort, Int32, Int32, Int32, Boolean)
Returns the grouped results. Returns null if the number of groups collected is <= groupOffset.
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 FieldCache, etc.)
Declaration
public virtual ITopGroups<TGroupValue> GetTopGroups<TGroupValue>(Sort withinGroupSort, int groupOffset, int withinGroupOffset, int maxDocsPerGroup, bool fillSortFields)
Parameters
Type | Name | Description |
---|---|---|
Sort | withinGroupSort | The Sort used to sort documents within each group. Passing null is allowed, to sort by relevance. |
System.Int32 | groupOffset | Which group to start from |
System.Int32 | withinGroupOffset | Which document to start from within each group |
System.Int32 | maxDocsPerGroup | How many top documents to keep within each group. |
System.Boolean | fillSortFields | If true then the Comparable values for the sort fields will be set |
Returns
Type | Description |
---|---|
ITopGroups<TGroupValue> |
Type Parameters
Name | Description |
---|---|
TGroupValue | The expected return type for group value |
SetNextReader(AtomicReaderContext)
Declaration
public virtual void SetNextReader(AtomicReaderContext context)
Parameters
Type | Name | Description |
---|---|---|
AtomicReaderContext | context |
SetScorer(Scorer)
Declaration
public virtual void SetScorer(Scorer scorer)
Parameters
Type | Name | Description |
---|---|---|
Scorer | scorer |