Class 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 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".
Inherited Members
Assembly: DistributedLucene.Net.dll
Syntax
public class FuzzyQuery : MultiTermQuery
Constructors
Name | Description |
---|---|
FuzzyQuery(Term) | Calls FuzzyQuery(Term, Int32). |
FuzzyQuery(Term, Int32) | |
FuzzyQuery(Term, Int32, Int32) | |
FuzzyQuery(Term, Int32, Int32, Int32, Boolean) | Create a new FuzzyQuery that will match terms with an edit distance
of at most |
Fields
Name | Description |
---|---|
DefaultMaxEdits | |
DefaultMaxExpansions | |
DefaultMinSimilarity | |
DefaultPrefixLength | |
DefaultTranspositions |
Properties
Name | Description |
---|---|
MaxEdits | |
PrefixLength | Returns 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. |
Term | Returns the pattern term. |
Transpositions | Returns |
Methods
Name | Description |
---|---|
Equals(Object) | |
GetHashCode() | |
GetTermsEnum(Terms, AttributeSource) | |
SingleToEdits(Single, Int32) | Helper function to convert from deprecated "minimumSimilarity" fractions to raw edit distances. NOTE: this was floatToEdits() in Lucene |
ToString(String) |