Class FirstPassGroupingCollector<T>

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

public class FirstPassGroupingCollector<T> extends org.apache.lucene.search.SimpleCollector
FirstPassGroupingCollector is the first of two passes necessary to collect grouped hits. This pass gathers the top N sorted groups. Groups are defined by a GroupSelector

See org.apache.lucene.search.grouping for more details including a full code example.

WARNING: This API is experimental and might change in incompatible ways in the next release.
  • Field Details

    • orderedGroups

      protected TreeSet<CollectedSearchGroup<T>> orderedGroups
      NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
  • Constructor Details

    • FirstPassGroupingCollector

      public FirstPassGroupingCollector(GroupSelector<T> groupSelector, org.apache.lucene.search.Sort groupSort, int topNGroups)
      Create the first pass collector.
      Parameters:
      groupSelector - a GroupSelector used to defined groups
      groupSort - The Sort used to sort the groups. The top sorted document within each group according to groupSort, determines how that group sorts against other groups. This must be non-null, ie, if you want to groupSort by relevance use Sort.RELEVANCE.
      topNGroups - How many top groups to keep.
  • Method Details

    • scoreMode

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

      public Collection<SearchGroup<T>> getTopGroups(int groupOffset) throws IOException
      Returns top groups, starting from offset. This may return null, if no groups were collected, or if the number of unique groups collected is <= offset.
      Parameters:
      groupOffset - The offset in the collected groups
      Returns:
      top groups, starting from offset
      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
    • 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
    • doSetNextReader

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

      public GroupSelector<T> getGroupSelector()
      Returns:
      the GroupSelector used for this Collector