Show / Hide Table of Contents

    Class AnalyzingInfixSuggester

    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, however the contexts must be valid utf8 (arbitrary binary terms will not work). @lucene.experimental

    Inheritance
    System.Object
    Lookup
    AnalyzingInfixSuggester
    BlendedInfixSuggester
    Implements
    IDisposable
    Inherited Members
    Lookup.CHARSEQUENCE_COMPARER
    Lookup.Build(IDictionary)
    Lookup.Load(Stream)
    Lookup.Store(Stream)
    Lookup.DoLookup(String, Boolean, Int32)
    Namespace: Lucene.Net.Search.Suggest.Analyzing
    Assembly: Lucene.Net.Suggest.dll
    Syntax
    public class AnalyzingInfixSuggester : Lookup, IDisposable

    Constructors

    | Improve this Doc View Source

    AnalyzingInfixSuggester(LuceneVersion, Store.Directory, Analyzer)

    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 Dispose() will also dispose the provided directory.

    Declaration
    public AnalyzingInfixSuggester(LuceneVersion matchVersion, Store.Directory dir, Analyzer analyzer)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    Store.Directory dir
    Analyzer analyzer
    | Improve this Doc View Source

    AnalyzingInfixSuggester(LuceneVersion, Store.Directory, Analyzer, Analyzer, Int32)

    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 Dispose() will also dispose the provided directory.

    Declaration
    public AnalyzingInfixSuggester(LuceneVersion matchVersion, Store.Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    Store.Directory dir
    Analyzer indexAnalyzer
    Analyzer queryAnalyzer
    System.Int32 minPrefixChars

    Minimum number of leading characters before is used (default 4). Prefixes shorter than this are indexed as character ngrams (increasing index size but making lookups faster).

    Fields

    | Improve this Doc View Source

    CONTEXTS_FIELD_NAME

    Field name used for the indexed context, as a and a , for filtering.

    Declaration
    protected const string CONTEXTS_FIELD_NAME = null
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    DEFAULT_MIN_PREFIX_CHARS

    Default minimum number of leading characters before PrefixQuery is used (4).

    Declaration
    public const int DEFAULT_MIN_PREFIX_CHARS = null
    Field Value
    Type Description
    System.Int32
    | Improve this Doc View Source

    EXACT_TEXT_FIELD_NAME

    Field name used for the indexed text, as a , for exact lookup.

    Declaration
    protected const string EXACT_TEXT_FIELD_NAME = null
    Field Value
    Type Description
    System.String
    | Improve this Doc View Source

    m_indexAnalyzer

    Analyzer used at index time

    Declaration
    protected readonly Analyzer m_indexAnalyzer
    Field Value
    Type Description
    Analyzer
    | Improve this Doc View Source

    m_queryAnalyzer

    Analyzer used at search time

    Declaration
    protected readonly Analyzer m_queryAnalyzer
    Field Value
    Type Description
    Analyzer
    | Improve this Doc View Source

    m_searcherMgr

    used for lookups.

    Declaration
    protected SearcherManager m_searcherMgr
    Field Value
    Type Description
    SearcherManager
    | Improve this Doc View Source

    TEXT_FIELD_NAME

    Field name used for the indexed text.

    Declaration
    protected const string TEXT_FIELD_NAME = null
    Field Value
    Type Description
    System.String

    Properties

    | Improve this Doc View Source

    Count

    Declaration
    public override long Count { get; }
    Property Value
    Type Description
    System.Int64
    Overrides
    Lookup.Count

    Methods

    | Improve this Doc View Source

    Add(BytesRef, IEnumerable<BytesRef>, Int64, BytesRef)

    Adds a new suggestion. Be sure to use Update(BytesRef, IEnumerable<BytesRef>, Int64, BytesRef) instead if you want to replace a previous suggestion. After adding or updating a batch of new suggestions, you must call Refresh() in the end in order to see the suggestions in DoLookup(String, IEnumerable<BytesRef>, Int32, Boolean, Boolean)

    Declaration
    public virtual void Add(BytesRef text, IEnumerable<BytesRef> contexts, long weight, BytesRef payload)
    Parameters
    Type Name Description
    BytesRef text
    IEnumerable<BytesRef> contexts
    System.Int64 weight
    BytesRef payload
    | Improve this Doc View Source

    AddNonMatch(StringBuilder, String)

    Called while highlighting a single result, to append a non-matching chunk of text from the suggestion to the provided fragments list.

    Declaration
    protected virtual void AddNonMatch(StringBuilder sb, string text)
    Parameters
    Type Name Description
    StringBuilder sb

    The to append to

    System.String text

    The text chunk to add

    | Improve this Doc View Source

    AddPrefixMatch(StringBuilder, String, String, String)

    Called while highlighting a single result, to append a matched prefix token, to the provided fragments list.

    Declaration
    protected virtual void AddPrefixMatch(StringBuilder sb, string surface, string analyzed, string prefixToken)
    Parameters
    Type Name Description
    StringBuilder sb

    The to append to

    System.String surface

    The fragment of the surface form (indexed during Build(IInputIterator), corresponding to this match

    System.String analyzed

    The analyzed token that matched

    System.String prefixToken

    The prefix of the token that matched

    | Improve this Doc View Source

    AddWholeMatch(StringBuilder, String, String)

    Called while highlighting a single result, to append the whole matched token to the provided fragments list.

    Declaration
    protected virtual void AddWholeMatch(StringBuilder sb, string surface, string analyzed)
    Parameters
    Type Name Description
    StringBuilder sb

    The to append to

    System.String surface

    The surface form (original) text

    System.String analyzed

    The analyzed token corresponding to the surface form text

    | Improve this Doc View Source

    Build(IInputIterator)

    Declaration
    public override void Build(IInputIterator iter)
    Parameters
    Type Name Description
    IInputIterator iter
    Overrides
    Lookup.Build(IInputIterator)
    | Improve this Doc View Source

    CreateResults(IndexSearcher, TopFieldDocs, Int32, String, Boolean, IEnumerable<String>, String)

    Create the results based on the search hits. Can be overridden by subclass to add particular behavior (e.g. weight transformation)

    Declaration
    protected virtual IList<Lookup.LookupResult> CreateResults(IndexSearcher searcher, TopFieldDocs hits, int num, string charSequence, bool doHighlight, IEnumerable<string> matchedTokens, string prefixToken)
    Parameters
    Type Name Description
    IndexSearcher searcher
    TopFieldDocs hits
    System.Int32 num
    System.String charSequence
    System.Boolean doHighlight
    IEnumerable<System.String> matchedTokens
    System.String prefixToken
    Returns
    Type Description
    IList<Lookup.LookupResult>
    | Improve this Doc View Source

    Dispose()

    Declaration
    public virtual void Dispose()
    | Improve this Doc View Source

    DoLookup(String, IEnumerable<BytesRef>, Boolean, Int32)

    Declaration
    public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, bool onlyMorePopular, int num)
    Parameters
    Type Name Description
    System.String key
    IEnumerable<BytesRef> contexts
    System.Boolean onlyMorePopular
    System.Int32 num
    Returns
    Type Description
    IList<Lookup.LookupResult>
    Overrides
    Lookup.DoLookup(String, IEnumerable<BytesRef>, Boolean, Int32)
    | Improve this Doc View Source

    DoLookup(String, IEnumerable<BytesRef>, Int32, Boolean, Boolean)

    Retrieve suggestions, specifying whether all terms must match (allTermsRequired) and whether the hits should be highlighted (doHighlight).

    Declaration
    public virtual IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, int num, bool allTermsRequired, bool doHighlight)
    Parameters
    Type Name Description
    System.String key
    IEnumerable<BytesRef> contexts
    System.Int32 num
    System.Boolean allTermsRequired
    System.Boolean doHighlight
    Returns
    Type Description
    IList<Lookup.LookupResult>
    | Improve this Doc View Source

    DoLookup(String, Int32, Boolean, Boolean)

    Lookup, without any context.

    Declaration
    public virtual IList<Lookup.LookupResult> DoLookup(string key, int num, bool allTermsRequired, bool doHighlight)
    Parameters
    Type Name Description
    System.String key
    System.Int32 num
    System.Boolean allTermsRequired
    System.Boolean doHighlight
    Returns
    Type Description
    IList<Lookup.LookupResult>
    | Improve this Doc View Source

    FinishQuery(BooleanQuery, Boolean)

    Subclass can override this to tweak the Query before searching.

    Declaration
    protected virtual Query FinishQuery(BooleanQuery bq, bool allTermsRequired)
    Parameters
    Type Name Description
    BooleanQuery bq
    System.Boolean allTermsRequired
    Returns
    Type Description
    Query
    | Improve this Doc View Source

    GetDirectory(DirectoryInfo)

    Subclass can override to choose a specific implementation.

    Declaration
    protected virtual Store.Directory GetDirectory(DirectoryInfo path)
    Parameters
    Type Name Description
    DirectoryInfo path
    Returns
    Type Description
    Store.Directory
    | Improve this Doc View Source

    GetIndexWriterConfig(LuceneVersion, Analyzer, OpenMode)

    Override this to customize index settings, e.g. which codec to use.

    Declaration
    protected virtual IndexWriterConfig GetIndexWriterConfig(LuceneVersion matchVersion, Analyzer indexAnalyzer, OpenMode openMode)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    Analyzer indexAnalyzer
    OpenMode openMode
    Returns
    Type Description
    IndexWriterConfig
    | Improve this Doc View Source

    GetLastTokenQuery(String)

    This is called if the last token isn't ended (e.g. user did not type a space after it). Return an appropriate clause to add to the .

    Declaration
    protected virtual Query GetLastTokenQuery(string token)
    Parameters
    Type Name Description
    System.String token
    Returns
    Type Description
    Query
    | Improve this Doc View Source

    GetSizeInBytes()

    Declaration
    public override long GetSizeInBytes()
    Returns
    Type Description
    System.Int64
    Overrides
    Lookup.GetSizeInBytes()
    | Improve this Doc View Source

    GetTextFieldType()

    Subclass can override this method to change the field type of the text field e.g. to change the index options

    Declaration
    protected virtual FieldType GetTextFieldType()
    Returns
    Type Description
    FieldType
    | Improve this Doc View Source

    Highlight(String, IEnumerable<String>, String)

    Override this method to customize the Object representing a single highlighted suggestions; the result is set on each HighlightKey member.

    Declaration
    protected virtual object Highlight(string text, IEnumerable<string> matchedTokens, string prefixToken)
    Parameters
    Type Name Description
    System.String text
    IEnumerable<System.String> matchedTokens
    System.String prefixToken
    Returns
    Type Description
    System.Object
    | Improve this Doc View Source

    Load(DataInput)

    Declaration
    public override bool Load(DataInput out)
    Parameters
    Type Name Description
    DataInput out
    Returns
    Type Description
    System.Boolean
    Overrides
    Lookup.Load(DataInput)
    | Improve this Doc View Source

    Refresh()

    Reopens the underlying searcher; it's best to "batch up" many additions/updates, and then call refresh once in the end.

    Declaration
    public virtual void Refresh()
    | Improve this Doc View Source

    Store(DataOutput)

    Declaration
    public override bool Store(DataOutput in)
    Parameters
    Type Name Description
    DataOutput in
    Returns
    Type Description
    System.Boolean
    Overrides
    Lookup.Store(DataOutput)
    | Improve this Doc View Source

    Update(BytesRef, IEnumerable<BytesRef>, Int64, BytesRef)

    Updates a previous suggestion, matching the exact same text as before. Use this to change the weight or payload of an already added suggstion. If you know this text is not already present you can use Add(BytesRef, IEnumerable<BytesRef>, Int64, BytesRef) instead. After adding or updating a batch of new suggestions, you must call Refresh() in the end in order to see the suggestions in DoLookup(String, IEnumerable<BytesRef>, Int32, Boolean, Boolean)

    Declaration
    public virtual void Update(BytesRef text, IEnumerable<BytesRef> contexts, long weight, BytesRef payload)
    Parameters
    Type Name Description
    BytesRef text
    IEnumerable<BytesRef> contexts
    System.Int64 weight
    BytesRef payload

    Implements

    IDisposable
    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Licensed to the Apache Software Foundation (ASF)