Module org.apache.lucene.grouping
Class GroupFacetCollector
- java.lang.Object
-
- org.apache.lucene.search.SimpleCollector
-
- org.apache.lucene.search.grouping.GroupFacetCollector
-
- All Implemented Interfaces:
Collector
,LeafCollector
- Direct Known Subclasses:
TermGroupFacetCollector
public abstract class GroupFacetCollector extends SimpleCollector
Base class for computing grouped facets.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GroupFacetCollector.FacetEntry
Represents a facet entry with a value and a count.static class
GroupFacetCollector.GroupedFacetResult
The grouped facet result.protected static class
GroupFacetCollector.SegmentResult
Contains the local grouped segment counts for a particular segment.private static class
GroupFacetCollector.SegmentResultPriorityQueue
-
Field Summary
Fields Modifier and Type Field Description protected int
endFacetOrd
protected java.lang.String
facetField
protected BytesRef
facetPrefix
protected java.lang.String
groupField
protected int[]
segmentFacetCounts
protected java.util.List<GroupFacetCollector.SegmentResult>
segmentResults
protected int
segmentTotalCount
protected int
startFacetOrd
-
Constructor Summary
Constructors Modifier Constructor Description protected
GroupFacetCollector(java.lang.String groupField, java.lang.String facetField, BytesRef facetPrefix)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract GroupFacetCollector.SegmentResult
createSegmentResult()
void
finish()
Hook that gets called once the leaf that is associated with this collector has finished collecting successfully, including when aCollectionTerminatedException
is thrown.GroupFacetCollector.GroupedFacetResult
mergeSegmentResults(int size, int minCount, boolean orderByCount)
Returns grouped facet results that were computed over zero or more segments.ScoreMode
scoreMode()
Indicates what features are required from the scorer.void
setScorer(Scorable scorer)
Called before successive calls toLeafCollector.collect(int)
.-
Methods inherited from class org.apache.lucene.search.SimpleCollector
collect, doSetNextReader, 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
collect, competitiveIterator
-
-
-
-
Field Detail
-
groupField
protected final java.lang.String groupField
-
facetField
protected final java.lang.String facetField
-
facetPrefix
protected final BytesRef facetPrefix
-
segmentResults
protected final java.util.List<GroupFacetCollector.SegmentResult> segmentResults
-
segmentFacetCounts
protected int[] segmentFacetCounts
-
segmentTotalCount
protected int segmentTotalCount
-
startFacetOrd
protected int startFacetOrd
-
endFacetOrd
protected int endFacetOrd
-
-
Constructor Detail
-
GroupFacetCollector
protected GroupFacetCollector(java.lang.String groupField, java.lang.String facetField, BytesRef facetPrefix)
-
-
Method Detail
-
mergeSegmentResults
public GroupFacetCollector.GroupedFacetResult mergeSegmentResults(int size, int minCount, boolean orderByCount) throws java.io.IOException
Returns grouped facet results that were computed over zero or more segments. Grouped facet counts are merged from zero or more segment results.- Parameters:
size
- The total number of facets to include. This is typically offset + limitminCount
- The minimum count a facet entry should have to be included in the grouped facet resultorderByCount
- Whether to sort the facet entries by facet entry count. Iffalse
then the facets are sorted lexicographically in ascending order.- Returns:
- grouped facet results
- Throws:
java.io.IOException
- If I/O related errors occur during merging segment grouped facet counts.
-
finish
public void finish() throws java.io.IOException
Description copied from interface:LeafCollector
Hook that gets called once the leaf that is associated with this collector has finished collecting successfully, including when aCollectionTerminatedException
is thrown. This is typically useful to compile data that has been collected on this leaf, e.g. to convert facet counts on leaf ordinals to facet counts on global ordinals. The default implementation does nothing.Note: It can be assumed that this method will only be called once per LeafCollector instance.
- Throws:
java.io.IOException
-
createSegmentResult
protected abstract GroupFacetCollector.SegmentResult createSegmentResult() throws java.io.IOException
- Throws:
java.io.IOException
-
setScorer
public void setScorer(Scorable scorer) throws java.io.IOException
Description copied from interface:LeafCollector
Called before successive calls toLeafCollector.collect(int)
. Implementations that need the score of the current document (passed-in toLeafCollector.collect(int)
), should save the passed-in Scorer and call scorer.score() when needed.- Specified by:
setScorer
in interfaceLeafCollector
- Overrides:
setScorer
in classSimpleCollector
- Throws:
java.io.IOException
-
-