C# Class Lucene.Net.Search.FuzzyQuery

Implements the fuzzy search query. The similarity measurement is based on the Damerau-Levenshtein (optimal string alignment) algorithm, though you can explicitly choose classic Levenshtein by passing false to the transpositions parameter.

this query uses MultiTermQuery.TopTermsScoringBooleanQueryRewrite as default. So terms will be collected and scored according to their edit distance. Only the top terms are used for building the BooleanQuery. It is not recommended to change the rewrite mode for fuzzy queries.

At most, this query will match terms up to {@value Lucene.Net.Util.Automaton.LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE} edits. Higher distances (especially with transpositions enabled), are generally not useful and will match a significant amount of the term dictionary. If you really want this, consider using an n-gram indexing technique (such as the SpellChecker in the suggest module) instead.

NOTE: terms of length 1 or 2 will sometimes not match because of how the scaled distance between two terms is computed. For a term to match, the edit distance between the terms must be less than the minimum length term (either the input term, or the candidate term). For example, FuzzyQuery on term "abcd" with maxEdits=2 will not match an indexed term "ab", and FuzzyQuery on term "a" with maxEdits=2 will not match an indexed term "abc".

Inheritance: MultiTermQuery
Afficher le fichier Open project: paulirwin/lucene.net Class Usage Examples

Méthodes publiques

Méthode Description
Equals ( object obj ) : bool
FuzzyQuery ( Term term ) : System

Calls #FuzzyQuery(Term, int) FuzzyQuery(term, defaultMaxEdits).

FuzzyQuery ( Term term, int maxEdits ) : System

Calls #FuzzyQuery(Term, int, int) FuzzyQuery(term, maxEdits, defaultPrefixLength).

FuzzyQuery ( Term term, int maxEdits, int prefixLength ) : System

Calls {@link #FuzzyQuery(Term, int, int, int, boolean) FuzzyQuery(term, maxEdits, prefixLength, defaultMaxExpansions, defaultTranspositions)}.

FuzzyQuery ( Term term, int maxEdits, int prefixLength, int maxExpansions, bool transpositions ) : System

Create a new FuzzyQuery that will match terms with an edit distance of at most maxEdits to term. If a prefixLength > 0 is specified, a common prefix of that length is also required.

GetHashCode ( ) : int
GetTermsEnum ( Terms terms, AttributeSource atts ) : TermsEnum
ToString ( string field ) : string

Private Methods

Méthode Description
FloatToEdits ( float minimumSimilarity, int termLen ) : int

Method Details

Equals() public méthode

public Equals ( object obj ) : bool
obj object
Résultat bool

FuzzyQuery() public méthode

Calls #FuzzyQuery(Term, int) FuzzyQuery(term, defaultMaxEdits).
public FuzzyQuery ( Term term ) : System
term Term
Résultat System

FuzzyQuery() public méthode

Calls #FuzzyQuery(Term, int, int) FuzzyQuery(term, maxEdits, defaultPrefixLength).
public FuzzyQuery ( Term term, int maxEdits ) : System
term Term
maxEdits int
Résultat System

FuzzyQuery() public méthode

Calls {@link #FuzzyQuery(Term, int, int, int, boolean) FuzzyQuery(term, maxEdits, prefixLength, defaultMaxExpansions, defaultTranspositions)}.
public FuzzyQuery ( Term term, int maxEdits, int prefixLength ) : System
term Term
maxEdits int
prefixLength int
Résultat System

FuzzyQuery() public méthode

Create a new FuzzyQuery that will match terms with an edit distance of at most maxEdits to term. If a prefixLength > 0 is specified, a common prefix of that length is also required.
public FuzzyQuery ( Term term, int maxEdits, int prefixLength, int maxExpansions, bool transpositions ) : System
term Term the term to search for
maxEdits int must be >= 0 and <= .
prefixLength int length of common (non-fuzzy) prefix
maxExpansions int the maximum number of terms to match. If this number is /// greater than when the query is rewritten, /// then the maxClauseCount will be used instead.
transpositions bool true if transpositions should be treated as a primitive /// edit operation. If this is false, comparisons will implement the classic /// Levenshtein algorithm.
Résultat System

GetHashCode() public méthode

public GetHashCode ( ) : int
Résultat int

GetTermsEnum() public méthode

public GetTermsEnum ( Terms terms, AttributeSource atts ) : TermsEnum
terms Terms
atts AttributeSource
Résultat TermsEnum

ToString() public méthode

public ToString ( string field ) : string
field string
Résultat string