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.
  • Field Details

    • groupField

      protected final String groupField
    • facetField

      protected final String facetField
    • facetPrefix

      protected final BytesRef facetPrefix
    • segmentResults

      protected final List<GroupFacetCollector.SegmentResult> segmentResults
    • segmentFacetCounts

      protected int[] segmentFacetCounts
    • segmentTotalCount

      protected int segmentTotalCount
    • startFacetOrd

      protected int startFacetOrd
    • endFacetOrd

      protected int endFacetOrd
  • Constructor Details

    • GroupFacetCollector

      protected GroupFacetCollector(String groupField, String facetField, BytesRef facetPrefix)
  • Method Details

    • mergeSegmentResults

      public GroupFacetCollector.GroupedFacetResult mergeSegmentResults(int size, int minCount, boolean orderByCount) throws 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 + limit
      minCount - The minimum count a facet entry should have to be included in the grouped facet result
      orderByCount - Whether to sort the facet entries by facet entry count. If false then the facets are sorted lexicographically in ascending order.
      Returns:
      grouped facet results
      Throws:
      IOException - If I/O related errors occur during merging segment grouped facet counts.
    • finish

      public void finish() throws 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 a CollectionTerminatedException 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:
      IOException
    • createSegmentResult

      protected abstract GroupFacetCollector.SegmentResult createSegmentResult() throws IOException
      Throws:
      IOException
    • setScorer

      public void setScorer(Scorable scorer) throws IOException
      Description copied from interface: LeafCollector
      Called before successive calls to LeafCollector.collect(int). Implementations that need the score of the current document (passed-in to LeafCollector.collect(int)), should save the passed-in Scorer and call scorer.score() when needed.
      Specified by:
      setScorer in interface LeafCollector
      Overrides:
      setScorer in class SimpleCollector
      Throws:
      IOException
    • scoreMode

      public ScoreMode scoreMode()
      Description copied from interface: Collector
      Indicates what features are required from the scorer.