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.
    • Field Detail

      • EXACT_TEXT_FIELD_NAME

        protected static final String EXACT_TEXT_FIELD_NAME
        Field name used for the indexed text, as a StringField, for exact lookup.
        See Also:
        Constant Field Values
      • CONTEXTS_FIELD_NAME

        protected static final String CONTEXTS_FIELD_NAME
        Field name used for the indexed context, as a StringField and a SortedSetDVField, for filtering.
        See Also:
        Constant Field Values
      • queryAnalyzer

        protected final Analyzer queryAnalyzer
        Analyzer used at search time
      • indexAnalyzer

        protected final Analyzer indexAnalyzer
        Analyzer used at index time
      • writer

        protected IndexWriter writer
        Used for ongoing NRT additions/updates.
      • searcherMgrLock

        protected final Object searcherMgrLock
        Used to manage concurrent access to searcherMgr
      • DEFAULT_MIN_PREFIX_CHARS

        public static final int DEFAULT_MIN_PREFIX_CHARS
        Default minimum number of leading characters before PrefixQuery is used (4).
        See Also:
        Constant Field Values
      • DEFAULT_ALL_TERMS_REQUIRED

        public static final boolean DEFAULT_ALL_TERMS_REQUIRED
        Default boolean clause option for multiple terms matching (all terms required).
        See Also:
        Constant Field Values
      • DEFAULT_HIGHLIGHT

        public static final boolean DEFAULT_HIGHLIGHT
        Default higlighting option.
        See Also:
        Constant Field Values
      • DEFAULT_CLOSE_INDEXWRITER_ON_BUILD

        protected static final boolean DEFAULT_CLOSE_INDEXWRITER_ON_BUILD
        Default option to close the IndexWriter once the index has been built.
        See Also:
        Constant Field Values
    • 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