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

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

# Class SuggestIndexSearcher

java.lang.Object
org.apache.lucene.search.IndexSearcher
org.apache.lucene.search.suggest.document.SuggestIndexSearcher

public class SuggestIndexSearcher extends IndexSearcher
Adds document suggest capabilities to IndexSearcher. Any `CompletionQuery` can be used to suggest documents.

Use `PrefixCompletionQuery` for analyzed prefix queries, `RegexCompletionQuery` for regular expression prefix queries, `FuzzyCompletionQuery` for analyzed prefix with typo tolerance and `ContextQuery` to boost and/or filter suggestions by contexts

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

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.apache.lucene.search.IndexSearcher

  `IndexSearcher.LeafReaderContextPartition, IndexSearcher.LeafSlice, IndexSearcher.TooManyClauses, IndexSearcher.TooManyNestedClauses`

- ## Field Summary

  ### Fields inherited from class org.apache.lucene.search.IndexSearcher

  `leafContexts, readerContext`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SuggestIndexSearcher(IndexReader reader)`
  Creates a searcher with document suggest capabilities for `reader`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `TopSuggestDocs`
  `suggest(CompletionQuery query, int n, boolean skipDuplicates)`
  Returns top `n` completion hits for `query`
  `void`
  `suggest(CompletionQuery query, TopSuggestDocsCollector collector)`
  Lower-level suggest API.

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

  `collectionStatistics, count, createWeight, explain, explain, getDefaultQueryCache, getDefaultQueryCachingPolicy, getDefaultSimilarity, getIndexReader, getLeafContexts, getMaxClauseCount, getQueryCache, getQueryCachingPolicy, getSimilarity, getSlices, getTaskExecutor, getTimeout, getTopReaderContext, rewrite, search, search, search, search, search, search, searchAfter, searchAfter, searchAfter, searchLeaf, setDefaultQueryCache, setDefaultQueryCachingPolicy, setMaxClauseCount, setQueryCache, setQueryCachingPolicy, setSimilarity, setTimeout, slices, slices, storedFields, termStatistics, timedOut, toString`

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

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

- ## Constructor Details

  - ### SuggestIndexSearcher

    public SuggestIndexSearcher(IndexReader reader)
    Creates a searcher with document suggest capabilities for `reader`.

- ## Method Details

  - ### suggest

    public TopSuggestDocs suggest(CompletionQuery query, int n, boolean skipDuplicates) throws IOException
    Returns top `n` completion hits for `query`
    Throws:
      `IOException`

  - ### suggest

    public void suggest(CompletionQuery query, TopSuggestDocsCollector collector) throws IOException
    Lower-level suggest API. Collects completion hits through `collector` for `query`.

    `TopSuggestDocsCollector.collect(int, CharSequence, CharSequence, float)` is called for every matching completion hit.

    Throws:
      `IOException`