Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class BlendedInfixSuggester

    Extension of the AnalyzingInfixSuggester which transforms the weight after search to take into account the position of the searched term into the indexed text. Please note that it increases the number of elements searched and applies the ponderation after. It might be costly for long suggestions.

    Note

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

    Inheritance
    object
    Lookup
    AnalyzingInfixSuggester
    BlendedInfixSuggester
    Implements
    IDisposable
    Inherited Members
    AnalyzingInfixSuggester.TEXT_FIELD_NAME
    AnalyzingInfixSuggester.EXACT_TEXT_FIELD_NAME
    AnalyzingInfixSuggester.CONTEXTS_FIELD_NAME
    AnalyzingInfixSuggester.m_queryAnalyzer
    AnalyzingInfixSuggester.m_indexAnalyzer
    AnalyzingInfixSuggester.m_searcherMgr
    AnalyzingInfixSuggester.DEFAULT_MIN_PREFIX_CHARS
    AnalyzingInfixSuggester.GetDirectory(DirectoryInfo)
    AnalyzingInfixSuggester.Build(IInputEnumerator)
    AnalyzingInfixSuggester.Commit()
    AnalyzingInfixSuggester.Add(BytesRef, IEnumerable<BytesRef>, long, BytesRef)
    AnalyzingInfixSuggester.Update(BytesRef, IEnumerable<BytesRef>, long, BytesRef)
    AnalyzingInfixSuggester.Refresh()
    AnalyzingInfixSuggester.DoLookup(string, int, bool, bool)
    AnalyzingInfixSuggester.GetLastTokenQuery(string)
    AnalyzingInfixSuggester.FinishQuery(BooleanQuery, bool)
    AnalyzingInfixSuggester.Highlight(string, ICollection<string>, string)
    AnalyzingInfixSuggester.AddNonMatch(StringBuilder, string)
    AnalyzingInfixSuggester.AddWholeMatch(StringBuilder, string, string)
    AnalyzingInfixSuggester.AddPrefixMatch(StringBuilder, string, string, string)
    AnalyzingInfixSuggester.Store(DataOutput)
    AnalyzingInfixSuggester.Load(DataInput)
    AnalyzingInfixSuggester.Dispose()
    AnalyzingInfixSuggester.Dispose(bool)
    AnalyzingInfixSuggester.GetSizeInBytes()
    AnalyzingInfixSuggester.Count
    Lookup.CHARSEQUENCE_COMPARER
    Lookup.Build(IDictionary)
    Lookup.Load(Stream)
    Lookup.Store(Stream)
    Lookup.DoLookup(string, bool, int)
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Lucene.Net.Search.Suggest.Analyzing
    Assembly: Lucene.Net.Suggest.dll
    Syntax
    public class BlendedInfixSuggester : AnalyzingInfixSuggester, IDisposable

    Constructors

    BlendedInfixSuggester(LuceneVersion, Directory, Analyzer)

    Create a new instance, loading from a previously built directory, if it exists.

    Declaration
    public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer analyzer)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    Directory dir
    Analyzer analyzer

    BlendedInfixSuggester(LuceneVersion, Directory, Analyzer, Analyzer, int, BlenderType, int)

    Create a new instance, loading from a previously built directory, if it exists.

    Declaration
    public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    Directory dir
    Analyzer indexAnalyzer
    Analyzer queryAnalyzer
    int minPrefixChars
    BlendedInfixSuggester.BlenderType blenderType

    Type of blending strategy, see BlenderType for more precisions

    int numFactor

    Factor to multiply the number of searched elements before ponderate

    Exceptions
    Type Condition
    IOException

    If there are problems opening the underlying Lucene index.

    BlendedInfixSuggester(LuceneVersion, Directory, Analyzer, Analyzer, int, BlenderType, int, bool)

    Create a new instance, loading from a previously built directory, if it exists.

    Declaration
    public BlendedInfixSuggester(LuceneVersion matchVersion, Directory dir, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int minPrefixChars, BlendedInfixSuggester.BlenderType blenderType, int numFactor, bool commitOnBuild)
    Parameters
    Type Name Description
    LuceneVersion matchVersion
    Directory dir
    Analyzer indexAnalyzer
    Analyzer queryAnalyzer
    int minPrefixChars
    BlendedInfixSuggester.BlenderType blenderType

    Type of blending strategy, see BlenderType for more precisions

    int numFactor

    Factor to multiply the number of searched elements before ponderate

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

    Exceptions
    Type Condition
    IOException

    If there are problems opening the underlying Lucene index.

    Fields

    DEFAULT_NUM_FACTOR

    Default factor

    Declaration
    public static int DEFAULT_NUM_FACTOR
    Field Value
    Type Description
    int

    LINEAR_COEF

    Coefficient used for linear blending

    Declaration
    protected static double LINEAR_COEF
    Field Value
    Type Description
    double

    Methods

    CalculateCoefficient(int)

    Calculate the weight coefficient based on the position of the first matching word. Subclass should override it to adapt it to particular needs

    Declaration
    protected virtual double CalculateCoefficient(int position)
    Parameters
    Type Name Description
    int position

    of the first matching word in text

    Returns
    Type Description
    double

    the coefficient

    CreateResults(IndexSearcher, TopFieldDocs, int, string, bool, ICollection<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 override IList<Lookup.LookupResult> CreateResults(IndexSearcher searcher, TopFieldDocs hits, int num, string key, bool doHighlight, ICollection<string> matchedTokens, string prefixToken)
    Parameters
    Type Name Description
    IndexSearcher searcher
    TopFieldDocs hits
    int num
    string key
    bool doHighlight
    ICollection<string> matchedTokens
    string prefixToken
    Returns
    Type Description
    IList<Lookup.LookupResult>
    Overrides
    AnalyzingInfixSuggester.CreateResults(IndexSearcher, TopFieldDocs, int, string, bool, ICollection<string>, string)
    Exceptions
    Type Condition
    IOException

    If there are problems reading fields from the underlying Lucene index.

    DoLookup(string, IEnumerable<BytesRef>, bool, int)

    Look up a key and return possible completion for this key.

    Declaration
    public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, bool onlyMorePopular, int num)
    Parameters
    Type Name Description
    string key

    lookup key. Depending on the implementation this may be a prefix, misspelling, or even infix.

    IEnumerable<BytesRef> contexts

    contexts to filter the lookup by, or null if all contexts are allowed; if the suggestion contains any of the contexts, it's a match

    bool onlyMorePopular

    return only more popular results

    int num

    maximum number of results to return

    Returns
    Type Description
    IList<Lookup.LookupResult>

    a list of possible completions, with their relative weight (e.g. popularity)

    Overrides
    AnalyzingInfixSuggester.DoLookup(string, IEnumerable<BytesRef>, bool, int)

    DoLookup(string, IEnumerable<BytesRef>, int, bool, bool)

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

    Declaration
    public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, int num, bool allTermsRequired, bool doHighlight)
    Parameters
    Type Name Description
    string key
    IEnumerable<BytesRef> contexts
    int num
    bool allTermsRequired
    bool doHighlight
    Returns
    Type Description
    IList<Lookup.LookupResult>
    Overrides
    AnalyzingInfixSuggester.DoLookup(string, IEnumerable<BytesRef>, int, bool, bool)

    GetTextFieldType()

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

    Declaration
    protected override FieldType GetTextFieldType()
    Returns
    Type Description
    FieldType
    Overrides
    AnalyzingInfixSuggester.GetTextFieldType()

    Implements

    IDisposable
    Back to top Copyright © 2024 The Apache Software Foundation, Licensed under the Apache License, Version 2.0
    Apache Lucene.Net, Lucene.Net, Apache, the Apache feather logo, and the Apache Lucene.Net project logo are trademarks of The Apache Software Foundation.
    All other marks mentioned may be trademarks or registered trademarks of their respective owners.