C# Class Lucene.Net.Search.Suggest.Analyzing.FuzzySuggester

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

At most, this query will match terms up to {@value org.apache.lucene.util.automaton.LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE} edits. Higher distances are not supported. Note that the fuzzy distance is measured in "byte space" on the bytes returned by the TokenStream's {@link TermToBytesRefAttribute}, usually UTF8. By default the analyzed bytes must be at least 3 {@link #DEFAULT_MIN_FUZZY_LENGTH} bytes before any edits are considered. Furthermore, the first 1 {@link #DEFAULT_NON_FUZZY_PREFIX} byte is not allowed to be edited. We allow up to 1 (@link #DEFAULT_MAX_EDITS} edit. If #unicodeAware parameter in the constructor is set to true, maxEdits, minFuzzyLength, transpositions and nonFuzzyPrefix are measured in Unicode code points (actual letters) instead of bytes.

NOTE: This suggester does not boost suggestions that required no edits over suggestions that did require edits. This is a known limitation.

Note: complex query analyzers can have a significant impact on the lookup performance. It's recommended to not use analyzers that drop or inject terms like synonyms to keep the complexity of the prefix intersection low for good lookup performance. At index time, complex analyzers can safely be used.

@lucene.experimental
Inheritance: AnalyzingSuggester
Exibir arquivo Open project: apache/lucenenet

Private Properties

Property Type Description
ToLevenshteinAutomata Lucene.Net.Util.Automaton.Automaton

Public Methods

Method Description
FuzzySuggester ( Analyzer analyzer ) : Lucene.Net.Analysis

Creates a FuzzySuggester instance initialized with default values.

FuzzySuggester ( Analyzer indexAnalyzer, Analyzer queryAnalyzer ) : Lucene.Net.Analysis

Creates a FuzzySuggester instance with an index & a query analyzer initialized with default values.

FuzzySuggester ( Analyzer indexAnalyzer, Analyzer queryAnalyzer, SuggesterOptions options, int maxSurfaceFormsPerAnalyzedForm, int maxGraphExpansions, bool preservePositionIncrements, int maxEdits, bool transpositions, int nonFuzzyPrefix, int minFuzzyLength, bool unicodeAware ) : Lucene.Net.Analysis

Creates a FuzzySuggester instance.

Protected Methods

Method Description
ConvertAutomaton ( Automaton a ) : Automaton
GetFullPrefixPaths ( BytesRef>.List prefixPaths, Automaton lookupAutomaton, BytesRef>.FST fst ) : BytesRef>.Pair>>.List

Private Methods

Method Description
ToLevenshteinAutomata ( Automaton automaton ) : Automaton

Method Details

ConvertAutomaton() protected method

protected ConvertAutomaton ( Automaton a ) : Automaton
a Lucene.Net.Util.Automaton.Automaton
return Lucene.Net.Util.Automaton.Automaton

FuzzySuggester() public method

Creates a FuzzySuggester instance initialized with default values.
public FuzzySuggester ( Analyzer analyzer ) : Lucene.Net.Analysis
analyzer Lucene.Net.Analysis.Analyzer The used for this suggester.
return Lucene.Net.Analysis

FuzzySuggester() public method

Creates a FuzzySuggester instance with an index & a query analyzer initialized with default values.
public FuzzySuggester ( Analyzer indexAnalyzer, Analyzer queryAnalyzer ) : Lucene.Net.Analysis
indexAnalyzer Lucene.Net.Analysis.Analyzer /// that will be used for analyzing suggestions while building the index.
queryAnalyzer Lucene.Net.Analysis.Analyzer /// that will be used for analyzing query text during lookup
return Lucene.Net.Analysis

FuzzySuggester() public method

Creates a FuzzySuggester instance.
public FuzzySuggester ( Analyzer indexAnalyzer, Analyzer queryAnalyzer, SuggesterOptions options, int maxSurfaceFormsPerAnalyzedForm, int maxGraphExpansions, bool preservePositionIncrements, int maxEdits, bool transpositions, int nonFuzzyPrefix, int minFuzzyLength, bool unicodeAware ) : Lucene.Net.Analysis
indexAnalyzer Lucene.Net.Analysis.Analyzer The that will be used for /// analyzing suggestions while building the index.
queryAnalyzer Lucene.Net.Analysis.Analyzer The that will be used for /// analyzing query text during lookup
options SuggesterOptions see ,
maxSurfaceFormsPerAnalyzedForm int Maximum number of /// surface forms to keep for a single analyzed form. /// When there are too many surface forms we discard the /// lowest weighted ones.
maxGraphExpansions int Maximum number of graph paths /// to expand from the analyzed form. Set this to -1 for /// no limit.
preservePositionIncrements bool Whether position holes should appear in the automaton
maxEdits int must be >= 0 and <= .
transpositions bool true if transpositions should be treated as a primitive /// edit operation. If this is false, comparisons will implement the classic /// Levenshtein algorithm.
nonFuzzyPrefix int length of common (non-fuzzy) prefix (see default
minFuzzyLength int minimum length of lookup key before any edits are allowed (see default )
unicodeAware bool operate Unicode code points instead of bytes.
return Lucene.Net.Analysis

GetFullPrefixPaths() protected method

protected GetFullPrefixPaths ( BytesRef>.List prefixPaths, Automaton lookupAutomaton, BytesRef>.FST fst ) : BytesRef>.Pair>>.List
prefixPaths BytesRef>.List
lookupAutomaton Lucene.Net.Util.Automaton.Automaton
fst BytesRef>.FST
return BytesRef>.Pair>>.List