Class CompletionSuggestionBuilder
java.lang.Object
org.opensearch.search.suggest.SuggestionBuilder<CompletionSuggestionBuilder>
org.opensearch.search.suggest.completion.CompletionSuggestionBuilder
- All Implemented Interfaces:
org.opensearch.core.common.io.stream.NamedWriteable
,org.opensearch.core.common.io.stream.Writeable
,org.opensearch.core.xcontent.ToXContent
,org.opensearch.core.xcontent.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.
- Opensearch.internal:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionprotected org.opensearch.core.common.bytes.BytesReference
protected FuzzyOptions
protected RegexOptions
protected boolean
static final String
Fields inherited from class org.opensearch.search.suggest.SuggestionBuilder
analyzer, ANALYZER_FIELD, field, FIELDNAME_FIELD, prefix, PREFIX_FIELD, regex, REGEX_FIELD, shardSize, SHARDSIZE_FIELD, size, SIZE_FIELD, text, TEXT_FIELD
Fields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionCompletionSuggestionBuilder
(org.opensearch.core.common.io.stream.StreamInput in) Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionbuild
(QueryShardContext context) Sets query contexts for completionprotected boolean
Indicates whether some otherSuggestionBuilder
of the same type is "equal to" this one.protected int
HashCode for the subclass ofSuggestionBuilder
to implement.void
doWriteTo
(org.opensearch.core.common.io.stream.StreamOutput out) static CompletionSuggestionBuilder
fromXContent
(org.opensearch.core.xcontent.XContentParser parser) protected org.opensearch.core.xcontent.XContentBuilder
innerToXContent
(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) Sets the prefix to provide completions for.Same asprefix(String)
with fuzziness offuzziness
prefix
(String prefix, FuzzyOptions fuzzyOptions) Same asprefix(String)
with full fuzzy options seeFuzzyOptions.Builder
Sets a regular expression pattern for prefixes to provide completions for.regex
(String regex, RegexOptions regexOptions) Same asregex(String)
with full regular expression options seeRegexOptions.Builder
boolean
Returns whether duplicate suggestions should be filtered out.skipDuplicates
(boolean skipDuplicates) Should duplicates be filtered or not.Methods inherited from class org.opensearch.search.suggest.SuggestionBuilder
analyzer, analyzer, equals, field, hashCode, populateCommonFields, prefix, regex, shardSize, shardSize, size, size, text, text, toXContent, writeTo
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensearch.core.xcontent.ToXContentFragment
isFragment
-
Field Details
-
SUGGESTION_NAME
- See Also:
-
fuzzyOptions
-
regexOptions
-
contextBytes
protected org.opensearch.core.common.bytes.BytesReference contextBytes -
skipDuplicates
protected boolean skipDuplicates
-
-
Constructor Details
-
CompletionSuggestionBuilder
-
CompletionSuggestionBuilder
public CompletionSuggestionBuilder(org.opensearch.core.common.io.stream.StreamInput in) throws IOException Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteTo
in classSuggestionBuilder<CompletionSuggestionBuilder>
- Throws:
IOException
-
prefix
Sets the prefix to provide completions for. The prefix gets analyzed by the suggest analyzer.- Overrides:
prefix
in 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:
regex
in classSuggestionBuilder<CompletionSuggestionBuilder>
-
regex
Same asregex(String)
with full regular expression options seeRegexOptions.Builder
-
contexts
public CompletionSuggestionBuilder contexts(Map<String, List<? extends org.opensearch.core.xcontent.ToXContent>> queryContexts) Sets query contexts for completion- Parameters:
queryContexts
- named query contexts seeCategoryQueryContext
andGeoQueryContext
-
skipDuplicates
public boolean skipDuplicates()Returns whether duplicate suggestions should be filtered out. -
skipDuplicates
Should duplicates be filtered or not. Defaults tofalse
. -
innerToXContent
protected org.opensearch.core.xcontent.XContentBuilder innerToXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException - Specified by:
innerToXContent
in classSuggestionBuilder<CompletionSuggestionBuilder>
- Throws:
IOException
-
fromXContent
public static CompletionSuggestionBuilder fromXContent(org.opensearch.core.xcontent.XContentParser parser) throws IOException - Throws:
IOException
-
build
public SuggestionSearchContext.SuggestionContext build(QueryShardContext context) throws IOException - Specified by:
build
in classSuggestionBuilder<CompletionSuggestionBuilder>
- Throws:
IOException
-
getWriteableName
-
doEquals
Description copied from class:SuggestionBuilder
Indicates whether some otherSuggestionBuilder
of the same type is "equal to" this one.- Specified by:
doEquals
in classSuggestionBuilder<CompletionSuggestionBuilder>
-
doHashCode
protected int doHashCode()Description copied from class:SuggestionBuilder
HashCode for the subclass ofSuggestionBuilder
to implement.- Specified by:
doHashCode
in classSuggestionBuilder<CompletionSuggestionBuilder>
-