Fork me on GitHub
  • API

    Show / Hide Table of Contents

    Class SlowFuzzyQuery

    Implements the classic fuzzy search query. The similarity measurement is based on the Levenshtein (edit distance) algorithm.

    Note that, unlike Lucene.Net.Search.FuzzyQuery, this query will silently allow for a (possibly huge) number of edit distances in comparisons, and may be extremely slow (comparing every term in the index).
    Inheritance
    object
    Query
    MultiTermQuery
    SlowFuzzyQuery
    Inherited Members
    MultiTermQuery.m_field
    MultiTermQuery.m_rewriteMethod
    MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE
    MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE
    MultiTermQuery.CONSTANT_SCORE_BOOLEAN_QUERY_REWRITE
    MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT
    MultiTermQuery.Field
    MultiTermQuery.GetTermsEnum(Terms)
    MultiTermQuery.Rewrite(IndexReader)
    MultiTermQuery.MultiTermRewriteMethod
    Query.Boost
    Query.ToString()
    Query.CreateWeight(IndexSearcher)
    Query.ExtractTerms(ISet<Term>)
    Query.Clone()
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Lucene.Net.Sandbox.Queries
    Assembly: Lucene.Net.Sandbox.dll
    Syntax
    [Obsolete("Use FuzzyQuery instead.")]
    public class SlowFuzzyQuery : MultiTermQuery

    Constructors

    SlowFuzzyQuery(Term)

    Calls SlowFuzzyQuery(term, defaultMinSimilarity, 0, defaultMaxExpansions).

    Declaration
    public SlowFuzzyQuery(Term term)
    Parameters
    Type Name Description
    Term term

    SlowFuzzyQuery(Term, float)

    Calls SlowFuzzyQuery(term, minimumSimilarity, 0, defaultMaxExpansions).

    Declaration
    public SlowFuzzyQuery(Term term, float minimumSimilarity)
    Parameters
    Type Name Description
    Term term
    float minimumSimilarity

    SlowFuzzyQuery(Term, float, int)

    Calls SlowFuzzyQuery(term, minimumSimilarity, prefixLength, defaultMaxExpansions).

    Declaration
    public SlowFuzzyQuery(Term term, float minimumSimilarity, int prefixLength)
    Parameters
    Type Name Description
    Term term
    float minimumSimilarity
    int prefixLength

    SlowFuzzyQuery(Term, float, int, int)

    Create a new SlowFuzzyQuery that will match terms with a similarity of at least minimumSimilarity to term. If a prefixLength > 0 is specified, a common prefix of that length is also required.

    Declaration
    public SlowFuzzyQuery(Term term, float minimumSimilarity, int prefixLength, int maxExpansions)
    Parameters
    Type Name Description
    Term term

    the term to search for

    float minimumSimilarity

    a value between 0 and 1 to set the required similarity between the query term and the matching terms. For example, for a minimumSimilarity of 0.5 a term of the same length as the query term is considered similar to the query term if the edit distance between both terms is less than length(term)*0.5

    Alternatively, if minimumSimilarity is >= 1f, it is interpreted as a pure Levenshtein edit distance. For example, a value of 2f will match all terms within an edit distance of 2 from the query term. Edit distances specified in this way may not be fractional.
    int prefixLength

    length of common (non-fuzzy) prefix

    int maxExpansions

    the maximum number of terms to match. If this number is greater than Lucene.Net.Search.BooleanQuery.MaxClauseCount when the query is rewritten, then the maxClauseCount will be used instead.

    Exceptions
    Type Condition
    ArgumentException

    if minimumSimilarity is >= 1 or < 0 or if prefixLength < 0

    Fields

    defaultMaxExpansions

    Implements the classic fuzzy search query. The similarity measurement is based on the Levenshtein (edit distance) algorithm.

    Note that, unlike Lucene.Net.Search.FuzzyQuery, this query will silently allow for a (possibly huge) number of edit distances in comparisons, and may be extremely slow (comparing every term in the index).
    Declaration
    public const int defaultMaxExpansions = 50
    Field Value
    Type Description
    int

    defaultMinSimilarity

    Implements the classic fuzzy search query. The similarity measurement is based on the Levenshtein (edit distance) algorithm.

    Note that, unlike Lucene.Net.Search.FuzzyQuery, this query will silently allow for a (possibly huge) number of edit distances in comparisons, and may be extremely slow (comparing every term in the index).
    Declaration
    public const float defaultMinSimilarity = 2
    Field Value
    Type Description
    float

    defaultPrefixLength

    Implements the classic fuzzy search query. The similarity measurement is based on the Levenshtein (edit distance) algorithm.

    Note that, unlike Lucene.Net.Search.FuzzyQuery, this query will silently allow for a (possibly huge) number of edit distances in comparisons, and may be extremely slow (comparing every term in the index).
    Declaration
    public const int defaultPrefixLength = 0
    Field Value
    Type Description
    int

    m_term

    Implements the classic fuzzy search query. The similarity measurement is based on the Levenshtein (edit distance) algorithm.

    Note that, unlike Lucene.Net.Search.FuzzyQuery, this query will silently allow for a (possibly huge) number of edit distances in comparisons, and may be extremely slow (comparing every term in the index).
    Declaration
    protected Term m_term
    Field Value
    Type Description
    Term

    Properties

    MinSimilarity

    Gets the minimum similarity that is required for this query to match. Returns float value between 0.0 and 1.0.

    Declaration
    public virtual float MinSimilarity { get; }
    Property Value
    Type Description
    float

    PrefixLength

    Gets the non-fuzzy prefix length. This is the number of characters at the start of a term that must be identical (not fuzzy) to the query term if the query is to match that term.

    Declaration
    public virtual int PrefixLength { get; }
    Property Value
    Type Description
    int

    Term

    Gets the pattern term.

    Declaration
    public virtual Term Term { get; }
    Property Value
    Type Description
    Term

    Methods

    Equals(object)

    Determines whether the specified object is equal to the current object.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with the current object.

    Returns
    Type Description
    bool

    true if the specified object is equal to the current object; otherwise, false.

    Overrides
    MultiTermQuery.Equals(object)

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for the current object.

    Overrides
    Lucene.Net.Search.MultiTermQuery.GetHashCode()

    GetTermsEnum(Terms, AttributeSource)

    Construct the enumeration to be used, expanding the pattern term. this method should only be called if the field exists (ie, implementations can assume the field does exist). this method should not return null (should instead return Lucene.Net.Index.TermsEnum.EMPTY if no terms match). The Lucene.Net.Index.TermsEnum must already be positioned to the first matching term. The given Lucene.Net.Util.AttributeSource is passed by the Lucene.Net.Search.MultiTermQuery.RewriteMethod to provide attributes, the rewrite method uses to inform about e.g. maximum competitive boosts. this is currently only used by Lucene.Net.Search.TopTermsRewrite<Q>.

    Declaration
    protected override TermsEnum GetTermsEnum(Terms terms, AttributeSource atts)
    Parameters
    Type Name Description
    Terms terms
    AttributeSource atts
    Returns
    Type Description
    TermsEnum
    Overrides
    Lucene.Net.Search.MultiTermQuery.GetTermsEnum(Lucene.Net.Index.Terms, Lucene.Net.Util.AttributeSource)

    ToString(string)

    Prints a query to a string, with field assumed to be the default field and omitted.

    Declaration
    public override string ToString(string field)
    Parameters
    Type Name Description
    string field
    Returns
    Type Description
    string
    Overrides
    Query.ToString(string)
    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.