Class TopSuggestDocsCollector

java.lang.Object
org.apache.lucene.search.SimpleCollector
org.apache.lucene.search.suggest.document.TopSuggestDocsCollector
All Implemented Interfaces:
Collector, LeafCollector

public class TopSuggestDocsCollector extends SimpleCollector
Collector that collects completion and score, along with document id

Non scoring collector that collect completions in order of their pre-computed scores.

NOTE: One document can be collected multiple times if a document is matched for multiple unique completions for a given query

Subclasses should only override collect(int, CharSequence, CharSequence, float).

NOTE: SimpleCollector.setScorer(org.apache.lucene.search.Scorable) and collect(int) is not used

  • Field Details

    • priorityQueue

      private final SuggestScoreDocPriorityQueue priorityQueue
    • num

      private final int num
    • pendingResults

      private final List<TopSuggestDocs.SuggestScoreDoc> pendingResults
      Only set if we are deduplicating hits: holds all per-segment hits until the end, when we dedup them
    • seenSurfaceForms

      final CharArraySet seenSurfaceForms
      Only set if we are deduplicating hits: holds all surface forms seen so far in the current segment
    • docBase

      protected int docBase
      Document base offset for the current Leaf
  • Constructor Details

    • TopSuggestDocsCollector

      public TopSuggestDocsCollector(int num, boolean skipDuplicates)
      Sole constructor

      Collects at most num completions with corresponding document and weight

  • Method Details

    • doSkipDuplicates

      protected boolean doSkipDuplicates()
      Returns true if duplicates are filtered out
    • getCountToCollect

      public int getCountToCollect()
      Returns the number of results to be collected
    • doSetNextReader

      protected void doSetNextReader(LeafReaderContext context) throws IOException
      Description copied from class: SimpleCollector
      This method is called before collecting context.
      Overrides:
      doSetNextReader in class SimpleCollector
      Throws:
      IOException
    • 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
    • collect

      public void collect(int docID, CharSequence key, CharSequence context, float score) throws IOException
      Called for every matched completion, similar to LeafCollector.collect(int) but for completions.

      NOTE: collection at the leaf level is guaranteed to be in descending order of score

      Throws:
      IOException
    • get

      public TopSuggestDocs get() throws IOException
      Returns at most num Top scoring TopSuggestDocss
      Throws:
      IOException
    • collect

      public void collect(int doc) throws IOException
      Ignored
      Specified by:
      collect in interface LeafCollector
      Specified by:
      collect in class SimpleCollector
      Throws:
      IOException
    • scoreMode

      public ScoreMode scoreMode()
      Ignored