TopSuggestDocsCollector (Lucene 10.5.1 suggest API)
Description: declaration: package: org.apache.lucene.search.suggest.document, class: TopSuggestDocsCollector

Package org.apache.lucene.search.suggest.document

# 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

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

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected int`
  `docBase`
  Document base offset for the current Leaf

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `TopSuggestDocsCollector(int num, boolean skipDuplicates)`
  Sole constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `collect(int doc)`
  Ignored
  `void`
  `collect(int docID, CharSequence key, CharSequence context, float score)`
  Called for every matched completion, similar to `LeafCollector.collect(int)` but for completions.
  `protected void`
  `doSetNextReader(LeafReaderContext context)`
  `protected boolean`
  `doSkipDuplicates()`
  Returns true if duplicates are filtered out
  `void`
  `finish()`
  `TopSuggestDocs`
  `get()`
  Returns at most `num` Top scoring `TopSuggestDocs`s
  `int`
  `getCountToCollect()`
  Returns the number of results to be collected
  `ScoreMode`
  `scoreMode()`
  Ignored

  ### Methods inherited from class org.apache.lucene.search.SimpleCollector

  `getLeafCollector, setScorer`

  ### 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.Collector

  `setWeight`

  ### Methods inherited from interface org.apache.lucene.search.LeafCollector

  `collect, collectRange, competitiveIterator`

- ## Field Details

  - ### 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
    Overrides:
      `doSetNextReader` in class `SimpleCollector`
    Throws:
      `IOException`

  - ### finish

    public void finish() throws IOException
    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 `TopSuggestDocs`s
    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