Class PhraseSuggesterDescriptor<T>
The phrase suggester adds additional logic on top of the term suggester to select entire corrected phrases instead of
individual tokens weighted based on ngram-language models. In practice this suggester will be able to make better decisions
about which tokens to pick based on co-occurrence and frequencies.
Inheritance
PhraseSuggesterDescriptor<T>
Assembly: OpenSearch.Client.dll
Syntax
public class PhraseSuggesterDescriptor<T> : SuggestDescriptorBase<PhraseSuggesterDescriptor<T>, IPhraseSuggester, T>, IDescriptor, IPhraseSuggester, ISuggester where T : class
Type Parameters
Methods
|
Edit this page
View Source
Collate(Func<PhraseSuggestCollateDescriptor<T>, IPhraseSuggestCollate>)
Checks each suggestion against the specified query to prune suggestions for which no matching docs exist in the index.
The collate query for a suggestion is run only on the local shard from which the suggestion has been generated from.
The query must be specified and can be templated. The current suggestion is automatically made available as
the {{suggestion}} variable, which should be used in your query. You can still specify your own template params ,
the suggestion value will be added to the variables you specify.
Additionally, you can specify a prune to control if all phrase suggestions will be returned; when set to true the
suggestions will have an additional option collate_match, which will be true if matching documents for the phrase was found,
false otherwise. The default value for prune is false.
Declaration
public PhraseSuggesterDescriptor<T> Collate(Func<PhraseSuggestCollateDescriptor<T>, IPhraseSuggestCollate> selector)
Parameters
Returns
|
Edit this page
View Source
Confidence(double?)
The confidence level defines a factor applied to the input phrases score which is used as a threshold for other suggest candidates.
Only candidates that score higher than the threshold will be included in the result.
For instance a confidence level of 1.0 will only return suggestions that score higher than the input phrase.
If set to 0.0 the top N candidates are returned. The default is 1.0.
Declaration
public PhraseSuggesterDescriptor<T> Confidence(double? confidence)
Parameters
Type |
Name |
Description |
double? |
confidence |
|
Returns
|
Edit this page
View Source
DirectGenerator(params Func<DirectGeneratorDescriptor<T>, IDirectGenerator>[])
Candidate generators used to produce a list of possible terms per term in the given text.
A single candidate generator is similar to a term suggester called for each individual term in the text.
The output of the generators is subsequently scored in combination with the candidates from the other terms for suggestion candidates.
Each of the generators is called per term in the original text.
Declaration
public PhraseSuggesterDescriptor<T> DirectGenerator(params Func<DirectGeneratorDescriptor<T>, IDirectGenerator>[] generators)
Parameters
Returns
|
Edit this page
View Source
ForceUnigrams(bool?)
Declaration
public PhraseSuggesterDescriptor<T> ForceUnigrams(bool? forceUnigrams = true)
Parameters
Type |
Name |
Description |
bool? |
forceUnigrams |
|
Returns
|
Edit this page
View Source
GramSize(int?)
Sets max size of the n-grams (shingles) in the field. If the field doesn’t contain n-grams (shingles), this should be omitted or set to 1.
Note that OpenSearch tries to detect the gram size based on the specified field. If the field uses a shingle filter,
the gram_size is set to the max_shingle_size if not explicitly set.
Declaration
public PhraseSuggesterDescriptor<T> GramSize(int? gramSize)
Parameters
Type |
Name |
Description |
int? |
gramSize |
|
Returns
|
Edit this page
View Source
Highlight(Func<PhraseSuggestHighlightDescriptor, IPhraseSuggestHighlight>)
Sets up suggestion highlighting. If not provided then no highlighted field is returned.
If provided must contain exactly pre_tag and post_tag, which are wrapped around the changed tokens.
If multiple tokens in a row are changed the entire phrase of changed tokens is wrapped rather than each token.
Declaration
public PhraseSuggesterDescriptor<T> Highlight(Func<PhraseSuggestHighlightDescriptor, IPhraseSuggestHighlight> selector)
Parameters
Returns
|
Edit this page
View Source
MaxErrors(double?)
The maximum percentage of the terms considered to be misspellings in order to form a correction.
This method accepts a float value in the range [0..1) as a fraction of the actual query terms or a number >=1 as an absolute number
of query terms. The default is set to 1.0, meaning only corrections with at most one misspelled term are returned.
Note that setting this too high can negatively impact performance. Low values like 1 or 2 are recommended; otherwise the time spend
in suggest calls might exceed the time spend in query execution.
Declaration
public PhraseSuggesterDescriptor<T> MaxErrors(double? maxErrors)
Parameters
Type |
Name |
Description |
double? |
maxErrors |
|
Returns
|
Edit this page
View Source
RealWordErrorLikelihood(double?)
The likelihood of a term being a misspelled even if the term exists in the dictionary.
The default is 0.95, meaning 5% of the real words are misspelled.
Declaration
public PhraseSuggesterDescriptor<T> RealWordErrorLikelihood(double? realWordErrorLikelihood)
Parameters
Type |
Name |
Description |
double? |
realWordErrorLikelihood |
|
Returns
|
Edit this page
View Source
Separator(char?)
The separator that is used to separate terms in the bigram field.
If not set the whitespace character is used as a separator.
Declaration
public PhraseSuggesterDescriptor<T> Separator(char? separator)
Parameters
Type |
Name |
Description |
char? |
separator |
|
Returns
|
Edit this page
View Source
ShardSize(int?)
Sets the maximum number of suggested terms to be retrieved from each individual shard.
During the reduce phase, only the top N suggestions are returned based on the size option. Defaults to 5.
Declaration
public PhraseSuggesterDescriptor<T> ShardSize(int? shardSize)
Parameters
Type |
Name |
Description |
int? |
shardSize |
|
Returns
|
Edit this page
View Source
Smoothing(Func<SmoothingModelContainerDescriptor, SmoothingModelContainer>)
Smoothing model to balance weight between infrequent grams (grams (shingles) are not existing in the index)
and frequent grams (appear at least once in the index).
Declaration
public PhraseSuggesterDescriptor<T> Smoothing(Func<SmoothingModelContainerDescriptor, SmoothingModelContainer> selector)
Parameters
Returns
|
Edit this page
View Source
Text(string)
Sets the text / query to provide suggestions for.
Declaration
public PhraseSuggesterDescriptor<T> Text(string text)
Parameters
Type |
Name |
Description |
string |
text |
|
Returns
|
Edit this page
View Source
TokenLimit(int?)
Declaration
public PhraseSuggesterDescriptor<T> TokenLimit(int? tokenLimit)
Parameters
Type |
Name |
Description |
int? |
tokenLimit |
|
Returns
Implements
Extension Methods