Class AnalyzingInfixSuggester

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Accountable
    Direct Known Subclasses:
    BlendedInfixSuggester

    public class AnalyzingInfixSuggester
    extends Lookup
    implements Closeable
    Analyzes the input text and then suggests matches based on prefix matches to any tokens in the indexed text. This also highlights the tokens that match.

    This suggester supports payloads. Matches are sorted only by the suggest weight; it would be nice to support blended score + weight sort in the future. This means this suggester best applies when there is a strong a-priori ranking of all the suggestions.

    This suggester supports contexts, including arbitrary binary terms.

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

      • AnalyzingInfixSuggester

        public AnalyzingInfixSuggester​(Directory dir,
                                       Analyzer analyzer)
                                throws IOException
        Create a new instance, loading from a previously built AnalyzingInfixSuggester directory, if it exists. This directory must be private to the infix suggester (i.e., not an external Lucene index). Note that close() will also close the provided directory.
        Throws:
        IOException
      • AnalyzingInfixSuggester

        public AnalyzingInfixSuggester​(Directory dir,
                                       Analyzer indexAnalyzer,
                                       Analyzer queryAnalyzer,
                                       int minPrefixChars,
                                       boolean commitOnBuild)
                                throws IOException
        Create a new instance, loading from a previously built AnalyzingInfixSuggester directory, if it exists. This directory must be private to the infix suggester (i.e., not an external Lucene index). Note that close() will also close the provided directory.
        Parameters:
        minPrefixChars - Minimum number of leading characters before PrefixQuery is used (default 4). Prefixes shorter than this are indexed as character ngrams (increasing index size but making lookups faster).
        commitOnBuild - Call commit after the index has finished building. This would persist the suggester index to disk and future instances of this suggester can use this pre-built dictionary.
        Throws:
        IOException
      • AnalyzingInfixSuggester

        public AnalyzingInfixSuggester​(Directory dir,
                                       Analyzer indexAnalyzer,
                                       Analyzer queryAnalyzer,
                                       int minPrefixChars,
                                       boolean commitOnBuild,
                                       boolean allTermsRequired,
                                       boolean highlight)
                                throws IOException
        Create a new instance, loading from a previously built AnalyzingInfixSuggester directory, if it exists. This directory must be private to the infix suggester (i.e., not an external Lucene index). Note that close() will also close the provided directory.
        Parameters:
        minPrefixChars - Minimum number of leading characters before PrefixQuery is used (default 4). Prefixes shorter than this are indexed as character ngrams (increasing index size but making lookups faster).
        commitOnBuild - Call commit after the index has finished building. This would persist the suggester index to disk and future instances of this suggester can use this pre-built dictionary.
        allTermsRequired - All terms in the suggest query must be matched.
        highlight - Highlight suggest query in suggestions.
        Throws:
        IOException
      • AnalyzingInfixSuggester

        public AnalyzingInfixSuggester​(Directory dir,
                                       Analyzer indexAnalyzer,
                                       Analyzer queryAnalyzer,
                                       int minPrefixChars,
                                       boolean commitOnBuild,
                                       boolean allTermsRequired,
                                       boolean highlight,
                                       boolean closeIndexWriterOnBuild)
                                throws IOException
        Create a new instance, loading from a previously built AnalyzingInfixSuggester directory, if it exists. This directory must be private to the infix suggester (i.e., not an external Lucene index). Note that close() will also close the provided directory.
        Parameters:
        minPrefixChars - Minimum number of leading characters before PrefixQuery is used (default 4). Prefixes shorter than this are indexed as character ngrams (increasing index size but making lookups faster).
        commitOnBuild - Call commit after the index has finished building. This would persist the suggester index to disk and future instances of this suggester can use this pre-built dictionary.
        allTermsRequired - All terms in the suggest query must be matched.
        highlight - Highlight suggest query in suggestions.
        closeIndexWriterOnBuild - If true, the IndexWriter will be closed after the index has finished building.
        Throws:
        IOException