public class TermSuggestionBuilder extends SuggestionBuilder<TermSuggestionBuilder>
Modifier and Type | Class and Description |
---|---|
static class |
TermSuggestionBuilder.StringDistanceImpl
An enum representing the valid string edit distance algorithms for determining suggestions.
|
static class |
TermSuggestionBuilder.SuggestMode
An enum representing the valid suggest modes.
|
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
analyzer, ANALYZER_FIELD, field, FIELDNAME_FIELD, prefix, PREFIX_FIELD, regex, REGEX_FIELD, shardSize, SHARDSIZE_FIELD, size, SIZE_FIELD, text, TEXT_FIELD
EMPTY_PARAMS
Constructor and Description |
---|
TermSuggestionBuilder(StreamInput in)
Read from a stream.
|
TermSuggestionBuilder(java.lang.String field) |
Modifier and Type | Method and Description |
---|---|
float |
accuracy()
Get the accuracy setting.
|
TermSuggestionBuilder |
accuracy(float accuracy)
s how similar the suggested terms at least need to be compared to the
original suggest text tokens.
|
SuggestionSearchContext.SuggestionContext |
build(QueryShardContext context) |
protected boolean |
doEquals(TermSuggestionBuilder other)
Indicates whether some other
SuggestionBuilder of the same type is "equal to" this one. |
protected int |
doHashCode()
HashCode for the subclass of
SuggestionBuilder to implement. |
void |
doWriteTo(StreamOutput out) |
static TermSuggestionBuilder |
fromXContent(XContentParser parser) |
java.lang.String |
getWriteableName()
Returns the name of the writeable object
|
XContentBuilder |
innerToXContent(XContentBuilder builder,
ToXContent.Params params) |
int |
maxEdits()
Get the maximum edit distance setting.
|
TermSuggestionBuilder |
maxEdits(int maxEdits)
Sets the maximum edit distance candidate suggestions can have in order to
be considered as a suggestion.
|
int |
maxInspections()
Get the factor for inspecting more candidate suggestions setting.
|
TermSuggestionBuilder |
maxInspections(int maxInspections)
A factor that is used to multiply with the size in order to inspect more
candidate suggestions.
|
float |
maxTermFreq()
Get the maximum term frequency threshold setting.
|
TermSuggestionBuilder |
maxTermFreq(float maxTermFreq)
Sets a maximum threshold in number of documents a suggest text token can
exist in order to be corrected.
|
float |
minDocFreq()
Get the minimal threshold for the frequency of a term appearing in the
document set setting.
|
TermSuggestionBuilder |
minDocFreq(float minDocFreq)
Sets a minimal threshold in number of documents a suggested term should
appear in.
|
int |
minWordLength()
Get the minimum length of a text term to be corrected setting.
|
TermSuggestionBuilder |
minWordLength(int minWordLength)
The minimum length a suggest text term must have in order to be
corrected.
|
int |
prefixLength()
Get the minimum prefix length that must match setting.
|
TermSuggestionBuilder |
prefixLength(int prefixLength)
Sets the number of minimal prefix characters that must match in order be
a candidate suggestion.
|
SortBy |
sort()
Get the sort setting.
|
TermSuggestionBuilder |
sort(SortBy sort)
Sets how to sort the suggest terms per suggest text token.
|
TermSuggestionBuilder.StringDistanceImpl |
stringDistance()
Get the string distance implementation setting.
|
TermSuggestionBuilder |
stringDistance(TermSuggestionBuilder.StringDistanceImpl stringDistance)
Sets what string distance implementation to use for comparing how similar
suggested terms are.
|
TermSuggestionBuilder.SuggestMode |
suggestMode()
Get the suggest mode setting.
|
TermSuggestionBuilder |
suggestMode(TermSuggestionBuilder.SuggestMode suggestMode)
The global suggest mode controls what suggested terms are included or
controls for what suggest text tokens, terms should be suggested for.
|
analyzer, analyzer, equals, field, hashCode, populateCommonFields, prefix, prefix, regex, regex, shardSize, shardSize, size, size, text, text, toXContent, writeTo
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
isFragment
public TermSuggestionBuilder(java.lang.String field)
public TermSuggestionBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
public void doWriteTo(StreamOutput out) throws java.io.IOException
doWriteTo
in class SuggestionBuilder<TermSuggestionBuilder>
java.io.IOException
public TermSuggestionBuilder suggestMode(TermSuggestionBuilder.SuggestMode suggestMode)
missing
- Only suggest terms in the suggest text that
aren't in the index. This is the default.
popular
- Only suggest terms that occur in more docs
then the original suggest text term.
always
- Suggest any matching suggest terms based on
tokens in the suggest text.
public TermSuggestionBuilder.SuggestMode suggestMode()
public TermSuggestionBuilder accuracy(float accuracy)
Default is 0.5
public float accuracy()
public TermSuggestionBuilder sort(SortBy sort)
score
- Sort should first be based on score, then
document frequency and then the term itself.
frequency
- Sort should first be based on document
frequency, then score and then the term itself.
What the score is depends on the suggester being used.
public SortBy sort()
public TermSuggestionBuilder stringDistance(TermSuggestionBuilder.StringDistanceImpl stringDistance)
internal
- This is the default and is based on
damerau_levenshtein
, but highly optimized for comparing
string distance for terms inside the index.
damerau_levenshtein
- String distance algorithm based on
Damerau-Levenshtein algorithm.
levenstein
- String distance algorithm based on
Levenstein edit distance algorithm.
jarowinkler
- String distance algorithm based on
Jaro-Winkler algorithm.
ngram
- String distance algorithm based on character
n-grams.
public TermSuggestionBuilder.StringDistanceImpl stringDistance()
public TermSuggestionBuilder maxEdits(int maxEdits)
public int maxEdits()
public TermSuggestionBuilder maxInspections(int maxInspections)
public int maxInspections()
public TermSuggestionBuilder maxTermFreq(float maxTermFreq)
This can be used to exclude high frequency terms from being suggested. High frequency terms are usually spelled correctly on top of this this also improves the suggest performance.
public float maxTermFreq()
public TermSuggestionBuilder prefixLength(int prefixLength)
public int prefixLength()
public TermSuggestionBuilder minWordLength(int minWordLength)
public int minWordLength()
public TermSuggestionBuilder minDocFreq(float minDocFreq)
public float minDocFreq()
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
innerToXContent
in class SuggestionBuilder<TermSuggestionBuilder>
java.io.IOException
public static TermSuggestionBuilder fromXContent(XContentParser parser) throws java.io.IOException
java.io.IOException
public SuggestionSearchContext.SuggestionContext build(QueryShardContext context) throws java.io.IOException
build
in class SuggestionBuilder<TermSuggestionBuilder>
java.io.IOException
public java.lang.String getWriteableName()
NamedWriteable
protected boolean doEquals(TermSuggestionBuilder other)
SuggestionBuilder
SuggestionBuilder
of the same type is "equal to" this one.doEquals
in class SuggestionBuilder<TermSuggestionBuilder>
protected int doHashCode()
SuggestionBuilder
SuggestionBuilder
to implement.doHashCode
in class SuggestionBuilder<TermSuggestionBuilder>