Class AbstractAllGroupHeadsCollector<GH extends AbstractAllGroupHeadsCollector.GroupHead>
- java.lang.Object
-
- org.apache.lucene.search.Collector
-
- org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector<GH>
-
- Direct Known Subclasses:
TermAllGroupHeadsCollector
public abstract class AbstractAllGroupHeadsCollector<GH extends AbstractAllGroupHeadsCollector.GroupHead> extends Collector
This collector specializes in collecting the most relevant document (group head) for each group that match the query.- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractAllGroupHeadsCollector.GroupHead<GROUP_VALUE_TYPE>
Represents a group head.protected class
AbstractAllGroupHeadsCollector.TemporalResult
Contains the result of group head retrieval.
-
Field Summary
Fields Modifier and Type Field Description protected int
compIDXEnd
protected int[]
reversed
protected AbstractAllGroupHeadsCollector.TemporalResult
temporalResult
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractAllGroupHeadsCollector(int numberOfSorts)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
acceptsDocsOutOfOrder()
Returntrue
if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) toCollector.collect(int)
.void
collect(int doc)
Called once for every document matching a query, with the unbased document number.protected abstract Collection<GH>
getCollectedGroupHeads()
Returns the collected group heads.int
groupHeadsSize()
protected abstract void
retrieveGroupHeadAndAddIfNotExist(int doc)
Returns the group head and puts it intotemporalResult
.int[]
retrieveGroupHeads()
FixedBitSet
retrieveGroupHeads(int maxDoc)
-
Methods inherited from class org.apache.lucene.search.Collector
setNextReader, setScorer
-
-
-
-
Field Detail
-
reversed
protected final int[] reversed
-
compIDXEnd
protected final int compIDXEnd
-
temporalResult
protected final AbstractAllGroupHeadsCollector.TemporalResult temporalResult
-
-
Method Detail
-
retrieveGroupHeads
public FixedBitSet retrieveGroupHeads(int maxDoc)
- Parameters:
maxDoc
- The maxDoc of the top levelIndexReader
.- Returns:
- an
FixedBitSet
containing all group heads.
-
retrieveGroupHeads
public int[] retrieveGroupHeads()
- Returns:
- an int array containing all group heads. The size of the array is equal to number of collected unique groups.
-
groupHeadsSize
public int groupHeadsSize()
- Returns:
- the number of group heads found for a query.
-
retrieveGroupHeadAndAddIfNotExist
protected abstract void retrieveGroupHeadAndAddIfNotExist(int doc) throws IOException
Returns the group head and puts it intotemporalResult
. If the group head wasn't encountered before then it will be added to the collected group heads. TheAbstractAllGroupHeadsCollector.TemporalResult.stop
property will betrue
if the group head wasn't encountered before otherwisefalse
.- Parameters:
doc
- The document to retrieve the group head for.- Throws:
IOException
- If I/O related errors occur
-
getCollectedGroupHeads
protected abstract Collection<GH> getCollectedGroupHeads()
Returns the collected group heads. Subsequent calls should return the same group heads.- Returns:
- the collected group heads
-
collect
public void collect(int doc) throws IOException
Description copied from class:Collector
Called once for every document matching a query, with the unbased document number.Note: This is called in an inner search loop. For good search performance, implementations of this method should not call
Searcher.doc(int)
orIndexReader.document(int)
on every hit. Doing so can slow searches by an order of magnitude or more.- Specified by:
collect
in classCollector
- Throws:
IOException
-
acceptsDocsOutOfOrder
public boolean acceptsDocsOutOfOrder()
Description copied from class:Collector
Returntrue
if this collector does not require the matching docIDs to be delivered in int sort order (smallest to largest) toCollector.collect(int)
.Most Lucene Query implementations will visit matching docIDs in order. However, some queries (currently limited to certain cases of
BooleanQuery
) can achieve faster searching if theCollector
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.- Specified by:
acceptsDocsOutOfOrder
in classCollector
-
-