Class AllGroupHeadsCollector<T>

java.lang.Object
org.apache.lucene.search.SimpleCollector
org.apache.lucene.search.grouping.AllGroupHeadsCollector<T>
All Implemented Interfaces:
org.apache.lucene.search.Collector, org.apache.lucene.search.LeafCollector

public abstract class AllGroupHeadsCollector<T> extends org.apache.lucene.search.SimpleCollector
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.
  • Field Details

    • sort

      protected final org.apache.lucene.search.Sort sort
    • reversed

      protected final int[] reversed
    • compIDXEnd

      protected final int compIDXEnd
    • heads

    • context

      protected org.apache.lucene.index.LeafReaderContext context
    • scorer

      protected org.apache.lucene.search.Scorable scorer
  • Method Details

    • newCollector

      public static <T> AllGroupHeadsCollector<T> newCollector(GroupSelector<T> selector, org.apache.lucene.search.Sort sort)
      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 groups
      sort - the within-group sort to use to choose the group head document
    • retrieveGroupHeads

      public org.apache.lucene.util.FixedBitSet retrieveGroupHeads(int maxDoc)
      Parameters:
      maxDoc - The maxDoc of the top level IndexReader.
      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

      protected Collection<? extends AllGroupHeadsCollector.GroupHead<T>> 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
      Specified by:
      collect in interface org.apache.lucene.search.LeafCollector
      Specified by:
      collect in class org.apache.lucene.search.SimpleCollector
      Throws:
      IOException
    • scoreMode

      public org.apache.lucene.search.ScoreMode scoreMode()
    • doSetNextReader

      protected void doSetNextReader(org.apache.lucene.index.LeafReaderContext context) throws IOException
      Overrides:
      doSetNextReader in class org.apache.lucene.search.SimpleCollector
      Throws:
      IOException
    • setScorer

      public void setScorer(org.apache.lucene.search.Scorable scorer) throws IOException
      Specified by:
      setScorer in interface org.apache.lucene.search.LeafCollector
      Overrides:
      setScorer in class org.apache.lucene.search.SimpleCollector
      Throws:
      IOException
    • newGroupHead

      protected abstract AllGroupHeadsCollector.GroupHead<T> newGroupHead(int doc, T value, org.apache.lucene.index.LeafReaderContext context, org.apache.lucene.search.Scorable scorer) throws IOException
      Create a new GroupHead for the given group value, initialized with a doc, context and scorer
      Throws:
      IOException