Module org.elasticsearch.server
Class CompletionSuggestionBuilder
java.lang.Object
org.elasticsearch.search.suggest.SuggestionBuilder<CompletionSuggestionBuilder>
org.elasticsearch.search.suggest.completion.CompletionSuggestionBuilder
- All Implemented Interfaces:
NamedWriteable,VersionedNamedWriteable,Writeable,ToXContent,ToXContentFragment
Defines a suggest command based on a prefix, typically to provide "auto-complete" functionality
for users as they type search terms. The implementation of the completion service uses FSTs that
are created at index-time and so must be defined in the mapping with the type "completion" before
indexing.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected BytesReferenceprotected FuzzyOptionsprotected RegexOptionsprotected booleanstatic final StringFields inherited from class org.elasticsearch.search.suggest.SuggestionBuilder
analyzer, ANALYZER_FIELD, field, FIELDNAME_FIELD, prefix, PREFIX_FIELD, regex, REGEX_FIELD, shardSize, SHARDSIZE_FIELD, size, SIZE_FIELD, text, TEXT_FIELDFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionRead from a stream. -
Method Summary
Modifier and TypeMethodDescriptionbuild(SearchExecutionContext context) contexts(Map<String, List<? extends ToXContent>> queryContexts) Sets query contexts for completionprotected booleanIndicates whether some otherSuggestionBuilderof the same type is "equal to" this one.protected intHashCode for the subclass ofSuggestionBuilderto implement.voiddoWriteTo(StreamOutput out) static CompletionSuggestionBuilderfromXContent(XContentParser parser) The minimal version of the recipient this object can be sent toReturns the name of the writeable objectprotected XContentBuilderinnerToXContent(XContentBuilder builder, ToXContent.Params params) Sets the prefix to provide completions for.Same asprefix(String)with fuzziness offuzzinessprefix(String prefix, FuzzyOptions fuzzyOptions) Same asprefix(String)with full fuzzy options seeFuzzyOptions.BuilderSets a regular expression pattern for prefixes to provide completions for.regex(String regex, RegexOptions regexOptions) Same asregex(String)with full regular expression options seeRegexOptions.BuilderskipDuplicates(boolean skipDuplicates) Should duplicates be filtered or not.Methods inherited from class org.elasticsearch.search.suggest.SuggestionBuilder
analyzer, analyzer, equals, field, hashCode, populateCommonFields, prefix, regex, shardSize, shardSize, size, size, text, text, toXContent, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
SUGGESTION_NAME
- See Also:
-
fuzzyOptions
-
regexOptions
-
contextBytes
-
skipDuplicates
protected boolean skipDuplicates
-
-
Constructor Details
-
CompletionSuggestionBuilder
-
CompletionSuggestionBuilder
Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classSuggestionBuilder<CompletionSuggestionBuilder>- Throws:
IOException
-
prefix
Sets the prefix to provide completions for. The prefix gets analyzed by the suggest analyzer.- Overrides:
prefixin classSuggestionBuilder<CompletionSuggestionBuilder>
-
prefix
Same asprefix(String)with fuzziness offuzziness -
prefix
Same asprefix(String)with full fuzzy options seeFuzzyOptions.Builder -
regex
Sets a regular expression pattern for prefixes to provide completions for.- Overrides:
regexin classSuggestionBuilder<CompletionSuggestionBuilder>
-
regex
Same asregex(String)with full regular expression options seeRegexOptions.Builder -
contexts
Sets query contexts for completion- Parameters:
queryContexts- named query contexts seeCategoryQueryContextandGeoQueryContext
-
skipDuplicates
Should duplicates be filtered or not. Defaults tofalse. -
innerToXContent
protected XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
innerToXContentin classSuggestionBuilder<CompletionSuggestionBuilder>- Throws:
IOException
-
fromXContent
- Throws:
IOException
-
build
public SuggestionSearchContext.SuggestionContext build(SearchExecutionContext context) throws IOException - Specified by:
buildin classSuggestionBuilder<CompletionSuggestionBuilder>- Throws:
IOException
-
getWriteableName
Description copied from interface:VersionedNamedWriteableReturns the name of the writeable object -
getMinimalSupportedVersion
Description copied from interface:VersionedNamedWriteableThe minimal version of the recipient this object can be sent to -
doEquals
Description copied from class:SuggestionBuilderIndicates whether some otherSuggestionBuilderof the same type is "equal to" this one.- Specified by:
doEqualsin classSuggestionBuilder<CompletionSuggestionBuilder>
-
doHashCode
protected int doHashCode()Description copied from class:SuggestionBuilderHashCode for the subclass ofSuggestionBuilderto implement.- Specified by:
doHashCodein classSuggestionBuilder<CompletionSuggestionBuilder>
-