Class AnalyzingSuggester
Suggester that first analyzes the surface form, adds the
analyzed form to a weighted FST, and then does the same
thing at lookup time. This means lookup is based on the
analyzed form while suggestions are still the surface
form(s).
This can result in powerful suggester functionality. For
example, if you use an analyzer removing stop words,
then the partial text "ghost chr..." could see the
suggestion "The Ghost of Christmas Past". Note that
position increments MUST NOT be preserved for this example
to work, so you should call the constructor with
Lucene.Net.Search.Suggest.Analyzing.AnalyzingSuggester.preservePositionIncrements parameter set to
false
If SynonymFilter is used to map wifi and wireless network to
hotspot then the partial text "wirele..." could suggest
"wifi router". Token normalization like stemmers, accent
removal, etc., would allow suggestions to ignore such
variations.
When two matching suggestions have the same weight, they
are tie-broken by the analyzed form. If their analyzed
form is the same then the order is undefined.
There are some limitations:
- A lookup from a query like "net" in English won't
be any different than "net " (ie, user added a
trailing space) because analyzers don't reflect
when they've seen a token separator and when they
haven't.
- If you're using StopFilter, and the user will
type "fast apple", but so far all they've typed is
"fast a", again because the analyzer doesn't convey whether
it's seen a token separator after the "a",
StopFilter will remove that "a" causing
far more matches than you'd expect.
- Lookups with the empty string return no results
instead of all results.
@lucene.experimental
Inheritance
System.Object
AnalyzingSuggester
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Assembly: Lucene.Net.Suggest.dll
Syntax
public class AnalyzingSuggester : Lookup
Constructors
|
Improve this Doc
View Source
AnalyzingSuggester(Analyzer)
Declaration
public AnalyzingSuggester(Analyzer analyzer)
Parameters
|
Improve this Doc
View Source
AnalyzingSuggester(Analyzer, Analyzer)
Declaration
public AnalyzingSuggester(Analyzer indexAnalyzer, Analyzer queryAnalyzer)
Parameters
|
Improve this Doc
View Source
AnalyzingSuggester(Analyzer, Analyzer, SuggesterOptions, Int32, Int32, Boolean)
Declaration
public AnalyzingSuggester(Analyzer indexAnalyzer, Analyzer queryAnalyzer, SuggesterOptions options, int maxSurfaceFormsPerAnalyzedForm, int maxGraphExpansions, bool preservePositionIncrements)
Parameters
Type |
Name |
Description |
Analyzer |
indexAnalyzer |
Analyzer that will be used for
analyzing suggestions while building the index.
|
Analyzer |
queryAnalyzer |
Analyzer that will be used for
analyzing query text during lookup
|
SuggesterOptions |
options |
see EXACT_FIRST, PRESERVE_SEP
|
System.Int32 |
maxSurfaceFormsPerAnalyzedForm |
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.
|
System.Int32 |
maxGraphExpansions |
Maximum number of graph paths
to expand from the analyzed form. Set this to -1 for
no limit.
|
System.Boolean |
preservePositionIncrements |
Whether position holes
should appear in the automata
|
Properties
|
Improve this Doc
View Source
Count
Declaration
public override long Count { get; }
Property Value
Type |
Description |
System.Int64 |
|
Overrides
Methods
|
Improve this Doc
View Source
Declaration
public override void Build(IInputIterator iterator)
Parameters
Overrides
|
Improve this Doc
View Source
ConvertAutomaton(Automaton)
Used by subclass to change the lookup automaton, if
necessary.
Declaration
protected virtual Automaton ConvertAutomaton(Automaton a)
Parameters
Returns
|
Improve this Doc
View Source
DoLookup(String, IEnumerable<BytesRef>, Boolean, Int32)
Declaration
public override IList<Lookup.LookupResult> DoLookup(string key, IEnumerable<BytesRef> contexts, bool onlyMorePopular, int num)
Parameters
Type |
Name |
Description |
System.String |
key |
|
System.Collections.Generic.IEnumerable<BytesRef> |
contexts |
|
System.Boolean |
onlyMorePopular |
|
System.Int32 |
num |
|
Returns
Overrides
|
Improve this Doc
View Source
Get(String)
Returns the weight associated with an input string,
or null if it does not exist.
Declaration
public virtual object Get(string key)
Parameters
Type |
Name |
Description |
System.String |
key |
|
Returns
Type |
Description |
System.Object |
|
|
Improve this Doc
View Source
GetFullPrefixPaths(IList<FSTUtil.Path<PairOutputs<Nullable<Int64>, BytesRef>.Pair>>, Automaton, FST<PairOutputs<Nullable<Int64>, BytesRef>.Pair>)
Returns all prefix paths to initialize the search.
Declaration
protected virtual IList<FSTUtil.Path<PairOutputs<long?, BytesRef>.Pair>> GetFullPrefixPaths(IList<FSTUtil.Path<PairOutputs<long?, BytesRef>.Pair>> prefixPaths, Automaton lookupAutomaton, FST<PairOutputs<long?, BytesRef>.Pair> fst)
Parameters
Returns
|
Improve this Doc
View Source
GetSizeInBytes()
Returns byte size of the underlying FST.
Declaration
public override long GetSizeInBytes()
Returns
Type |
Description |
System.Int64 |
|
Overrides
|
Improve this Doc
View Source
Declaration
public override bool Load(DataInput input)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides
|
Improve this Doc
View Source
Store(DataOutput)
Declaration
public override bool Store(DataOutput output)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Overrides