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

# Class NRTSuggester

java.lang.Object
org.apache.lucene.search.suggest.document.NRTSuggester

All Implemented Interfaces:
  `Accountable`

public final class NRTSuggester extends Object implements Accountable
NRTSuggester executes Top N search on a weighted FST specified by a `CompletionScorer`

See `lookup(CompletionScorer, Bits, TopSuggestDocsCollector)` for more implementation details.

FST Format:

- Input: analyzed forms of input terms
- Output: Pair<Long, BytesRef> containing weight, surface form and docID

NOTE:

- having too many deletions or using a very restrictive filter can make the search inadmissible due to over-pruning of potential paths. See `CompletionScorer.accept(int, Bits)`
- when matched documents are arbitrarily filtered (`CompletionScorer.filtered` set to `true`, it is assumed that the filter will roughly filter out half the number of documents that match the provided automaton
- lookup performance will degrade as more accepted completions lead to filtered out documents

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

- ## Field Summary

  ### Fields inherited from interface org.apache.lucene.util.Accountable

  `NULL_ACCOUNTABLE`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Collection<Accountable>`
  `getChildResources()`
  `void`
  `lookup(CompletionScorer scorer, Bits acceptDocs, TopSuggestDocsCollector collector)`
  Collects at most `TopSuggestDocsCollector.getCountToCollect()` completions that match the provided `CompletionScorer`.
  `long`
  `ramBytesUsed()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### ramBytesUsed

    public long ramBytesUsed()
    Specified by:
      `ramBytesUsed` in interface `Accountable`

  - ### getChildResources

    public Collection<Accountable> getChildResources()
    Specified by:
      `getChildResources` in interface `Accountable`

  - ### lookup

    public void lookup(CompletionScorer scorer, Bits acceptDocs, TopSuggestDocsCollector collector) throws IOException
    Collects at most `TopSuggestDocsCollector.getCountToCollect()` completions that match the provided `CompletionScorer`.

    The `CompletionScorer.automaton` is intersected with the `fst`. `CompletionScorer.weight` is used to compute boosts and/or extract context for each matched partial paths. A top N search is executed on `fst` seeded with the matched partial paths. Upon reaching a completed path, `CompletionScorer.accept(int, Bits)` and `CompletionScorer.score(float, float)` is used on the document id, index weight and query boost to filter and score the entry, before being collected via `TopSuggestDocsCollector.collect(int, CharSequence, CharSequence, float)`

    Throws:
      `IOException`