Class AbstractFirstPassGroupingCollector<TGroupValue>
FirstPassGroupingCollector is the first of two passes necessary to collect grouped hits. This pass gathers the top N sorted groups. Concrete subclasses define what a group is and how it is internally collected.
See org.apache.lucene.search.grouping for more details including a full code example.
Note
This API is experimental and might change in incompatible ways in the next release.
Inheritance
Inherited Members
Namespace: Lucene.Net.Search.Grouping
Assembly: Lucene.Net.Grouping.dll
Syntax
public abstract class AbstractFirstPassGroupingCollector<TGroupValue> : IAbstractFirstPassGroupingCollector<TGroupValue>, ICollector
Type Parameters
| Name | Description |
|---|---|
| TGroupValue |
Constructors
AbstractFirstPassGroupingCollector(Sort, int)
Create the first pass collector.
Declaration
protected AbstractFirstPassGroupingCollector(Sort groupSort, int topNGroups)
Parameters
| Type | Name | Description |
|---|---|---|
| Sort | groupSort | The Lucene.Net.Search.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 Sort.RELEVANCE. |
| int | topNGroups | How many top groups to keep. |
Exceptions
| Type | Condition |
|---|---|
| IOException | If I/O related errors occur |
Fields
m_orderedGroups
FirstPassGroupingCollector is the first of two passes necessary to collect grouped hits. This pass gathers the top N sorted groups. Concrete subclasses define what a group is and how it is internally collected.
See org.apache.lucene.search.grouping for more details including a full code example.
Note
This API is experimental and might change in incompatible ways in the next release.
Declaration
protected SortedSet<CollectedSearchGroup<TGroupValue>> m_orderedGroups
Field Value
| Type | Description |
|---|---|
| SortedSet<CollectedSearchGroup<TGroupValue>> |
Properties
AcceptsDocsOutOfOrder
Return true if this collector does not
require the matching docIDs to be delivered in int sort
order (smallest to largest) to Collect(int).
Most Lucene Query implementations will visit matching docIDs in order. However, some queries (currently limited to certain cases of Lucene.Net.Search.BooleanQuery) can achieve faster searching if the Lucene.Net.Search.ICollector allows them to deliver the docIDs out of order.
Many collectors don't mind getting docIDs out of
order, so it's important to return true
here.
Declaration
public virtual bool AcceptsDocsOutOfOrder { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
Collect(int)
Called once for every document matching a query, with the unbased document number.
Note: The collection of the current segment can be terminated by throwing a Lucene.Net.Search.CollectionTerminatedException. In this case, the last docs of the current Lucene.Net.Index.AtomicReaderContext will be skipped and Lucene.Net.Search.IndexSearcher will swallow the exception and continue collection with the next leaf. Note: this is called in an inner search loop. For good search performance, implementations of this method should not call Doc(int) or Document(int) on every hit. Doing so can slow searches by an order of magnitude or more.Declaration
public virtual void Collect(int doc)
Parameters
| Type | Name | Description |
|---|---|---|
| int | doc |
CopyDocGroupValue(TGroupValue, TGroupValue)
Returns a copy of the specified group value by creating a new instance and copying the value from the specified groupValue in the new instance. Or optionally the reuse argument can be used to copy the group value in.
Declaration
protected abstract TGroupValue CopyDocGroupValue(TGroupValue groupValue, TGroupValue reuse)
Parameters
| Type | Name | Description |
|---|---|---|
| TGroupValue | groupValue | The group value to copy |
| TGroupValue | reuse | Optionally a reuse instance to prevent a new instance creation |
Returns
| Type | Description |
|---|---|
| TGroupValue | a copy of the specified group value |
GetDocGroupValue(int)
Returns the group value for the specified doc.
Declaration
protected abstract TGroupValue GetDocGroupValue(int doc)
Parameters
| Type | Name | Description |
|---|---|---|
| int | doc | The specified doc |
Returns
| Type | Description |
|---|---|
| TGroupValue | the group value for the specified doc |
GetTopGroups(int, bool)
Returns top groups, starting from offset. This may return null, if no groups were collected, or if the number of unique groups collected is <= offset.
Declaration
public virtual IEnumerable<ISearchGroup<TGroupValue>> GetTopGroups(int groupOffset, bool fillFields)
Parameters
| Type | Name | Description |
|---|---|---|
| int | groupOffset | The offset in the collected groups |
| bool | fillFields | Whether to fill to SortValues |
Returns
| Type | Description |
|---|---|
| IEnumerable<ISearchGroup<TGroupValue>> | top groups, starting from offset |
SetNextReader(AtomicReaderContext)
Called before collecting from each Lucene.Net.Index.AtomicReaderContext. All doc ids in Collect(int) will correspond to Lucene.Net.Index.IndexReaderContext.Reader.
Add Lucene.Net.Index.AtomicReaderContext.DocBase to the current Lucene.Net.Index.IndexReaderContext.Reader's internal document id to re-base ids in Collect(int).Declaration
public virtual void SetNextReader(AtomicReaderContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| AtomicReaderContext | context | next atomic reader context |
SetScorer(Scorer)
Called before successive calls to Collect(int). Implementations
that need the score of the current document (passed-in to
Collect(int)), should save the passed-in Lucene.Net.Search.Scorer and call
scorer.GetScore() when needed.
Declaration
public virtual void SetScorer(Scorer scorer)
Parameters
| Type | Name | Description |
|---|---|---|
| Scorer | scorer |