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

    All Methods Instance Methods Concrete Methods
    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, doc, doc, doc, explain, explain, getDefaultQueryCache, getDefaultQueryCachingPolicy, getDefaultSimilarity, getExecutor, getIndexReader, getLeafContexts, getMaxClauseCount, getQueryCache, getQueryCachingPolicy, getSimilarity, getSlices, getTaskExecutor, getTopReaderContext, rewrite, search, search, search, search, search, search, searchAfter, searchAfter, searchAfter, 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 Detail

    - #### SuggestIndexSearcher

          public SuggestIndexSearcher​(IndexReader reader)

      Creates a searcher with document suggest capabilities for `reader`.

  - ### Method Detail

    - #### 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`