Class AllGroupHeadsCollector<T>
java.lang.Object
org.apache.lucene.search.SimpleCollector
org.apache.lucene.search.grouping.AllGroupHeadsCollector<T>
- All Implemented Interfaces:
Collector
,LeafCollector
This collector specializes in collecting the most relevant document (group head) for each group
that matches the query.
Clients should create new collectors by calling newCollector(GroupSelector, Sort)
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents a group head. -
Field Summary
Modifier and TypeFieldDescriptionprotected final int
protected LeafReaderContext
protected Map<T,
AllGroupHeadsCollector.GroupHead<T>> protected final int[]
protected Scorable
protected final Sort
-
Method Summary
Modifier and TypeMethodDescriptionvoid
collect
(int doc) protected void
doSetNextReader
(LeafReaderContext context) protected Collection<? extends AllGroupHeadsCollector.GroupHead<T>>
Returns the collected group heads.int
static <T> AllGroupHeadsCollector<T>
newCollector
(GroupSelector<T> selector, Sort sort) Create a new AllGroupHeadsCollector based on the type of within-group Sort requiredprotected abstract AllGroupHeadsCollector.GroupHead<T>
newGroupHead
(int doc, T value, LeafReaderContext context, Scorable scorer) Create a new GroupHead for the given group value, initialized with a doc, context and scorerint[]
retrieveGroupHeads
(int maxDoc) void
Methods inherited from class org.apache.lucene.search.SimpleCollector
getLeafCollector
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.lucene.search.LeafCollector
competitiveIterator
-
Field Details
-
sort
-
reversed
protected final int[] reversed -
compIDXEnd
protected final int compIDXEnd -
heads
-
context
-
scorer
-
-
Method Details
-
newCollector
Create a new AllGroupHeadsCollector based on the type of within-group Sort required- Type Parameters:
T
- the group value type- Parameters:
selector
- a GroupSelector to define the groupssort
- the within-group sort to use to choose the group head document
-
retrieveGroupHeads
- Parameters:
maxDoc
- The maxDoc of the top levelIndexReader
.- Returns:
- a
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.
-
getCollectedGroupHeads
Returns the collected group heads. Subsequent calls should return the same group heads.- Returns:
- the collected group heads
-
collect
- Specified by:
collect
in interfaceLeafCollector
- Specified by:
collect
in classSimpleCollector
- Throws:
IOException
-
scoreMode
-
doSetNextReader
- Overrides:
doSetNextReader
in classSimpleCollector
- Throws:
IOException
-
setScorer
- Specified by:
setScorer
in interfaceLeafCollector
- Overrides:
setScorer
in classSimpleCollector
- Throws:
IOException
-
newGroupHead
protected abstract AllGroupHeadsCollector.GroupHead<T> newGroupHead(int doc, T value, LeafReaderContext context, Scorable scorer) throws IOException Create a new GroupHead for the given group value, initialized with a doc, context and scorer- Throws:
IOException
-