Module org.elasticsearch.server
Package org.elasticsearch.search.suggest
Class SuggestionBuilder<T extends SuggestionBuilder<T>>
java.lang.Object
org.elasticsearch.search.suggest.SuggestionBuilder<T>
- All Implemented Interfaces:
- NamedWriteable,- VersionedNamedWriteable,- Writeable,- ToXContent,- ToXContentFragment
- Direct Known Subclasses:
- CompletionSuggestionBuilder,- PhraseSuggestionBuilder,- TermSuggestionBuilder
public abstract class SuggestionBuilder<T extends SuggestionBuilder<T>>
extends Object
implements VersionedNamedWriteable, ToXContentFragment
Base class for the different suggestion implementations.
- 
Nested Class SummaryNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContentToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.WriteableWriteable.Reader<V>, Writeable.Writer<V>
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Stringprotected static final ParseFieldprotected final Stringprotected static final ParseFieldprotected Stringprotected static final ParseFieldprotected Stringprotected static final ParseFieldprotected Integerprotected static final ParseFieldprotected Integerprotected static final ParseFieldprotected Stringprotected static final ParseFieldFields inherited from interface org.elasticsearch.xcontent.ToXContentEMPTY_PARAMS
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedSuggestionBuilder(String field) Creates a new suggestion.protectedSuggestionBuilder(String field, SuggestionBuilder<?> in) internal copy constructor that copies over all class fields from second SuggestionBuilder except field name.protectedRead from a stream.
- 
Method SummaryModifier and TypeMethodDescriptionanalyzer()get theanalyzer()parameterSets the analyzer to analyse to suggest text with.protected abstract SuggestionSearchContext.SuggestionContextbuild(SearchExecutionContext context) protected abstract booleanIndicates whether some otherSuggestionBuilderof the same type is "equal to" this one.protected abstract intHashCode for the subclass ofSuggestionBuilderto implement.protected abstract voiddoWriteTo(StreamOutput out) final booleanfield()get thefield()parameterfinal inthashCode()protected abstract XContentBuilderinnerToXContent(XContentBuilder builder, ToXContent.Params params) protected voidpopulateCommonFields(SearchExecutionContext context, SuggestionSearchContext.SuggestionContext suggestionContext) Transfers the text, prefix, regex, analyzer, field, size and shard size settings from the originalSuggestionBuilderto the targetSuggestionSearchContext.SuggestionContextprefix()get the prefix for this suggestionprotected Tregex()get the regex for this suggestionprotected Tget theshardSize()parameterSets the maximum number of suggested term to be retrieved from each individual shard.size()get thesize()parametersize(int size) Sets the maximum suggestions to be returned per suggest text term.text()get the text for this suggestionSame as inSuggestBuilder.setGlobalText(String), but in the suggestion scope.toXContent(XContentBuilder builder, ToXContent.Params params) final voidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragmentisFragmentMethods inherited from interface org.elasticsearch.common.io.stream.VersionedNamedWriteablegetMinimalSupportedVersion, getWriteableName
- 
Field Details- 
field
- 
text
- 
prefix
- 
regex
- 
analyzer
- 
size
- 
shardSize
- 
TEXT_FIELD
- 
PREFIX_FIELD
- 
REGEX_FIELD
- 
FIELDNAME_FIELD
- 
ANALYZER_FIELD
- 
SIZE_FIELD
- 
SHARDSIZE_FIELD
 
- 
- 
Constructor Details- 
SuggestionBuilderCreates a new suggestion.- Parameters:
- field- field to execute suggestions on
 
- 
SuggestionBuilderinternal copy constructor that copies over all class fields from second SuggestionBuilder except field name.
- 
SuggestionBuilderRead from a stream.- Throws:
- IOException
 
 
- 
- 
Method Details- 
writeToDescription copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
- writeToin interface- Writeable
- Throws:
- IOException
 
- 
doWriteTo- Throws:
- IOException
 
- 
textSame as inSuggestBuilder.setGlobalText(String), but in the suggestion scope.
- 
textget the text for this suggestion
- 
prefix
- 
prefixget the prefix for this suggestion
- 
regex
- 
regexget the regex for this suggestion
- 
fieldget thefield()parameter
- 
analyzerSets the analyzer to analyse to suggest text with. Defaults to the search analyzer of the suggest field.
- 
analyzerget theanalyzer()parameter
- 
sizeSets the maximum suggestions to be returned per suggest text term.
- 
sizeget thesize()parameter
- 
shardSizeSets the maximum number of suggested term to be retrieved from each individual shard. During the reduce phase the only the top N suggestions are returned based on thesizeoption. Defaults to thesizeoption.Setting this to a value higher than the `size` can be useful in order to get a more accurate document frequency for suggested terms. Due to the fact that terms are partitioned amongst shards, the shard level document frequencies of suggestions may not be precise. Increasing this will make these document frequencies more precise. 
- 
shardSizeget theshardSize()parameter
- 
toXContentpublic XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
- toXContentin interface- ToXContent
- Throws:
- IOException
 
- 
innerToXContentprotected abstract XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Throws:
- IOException
 
- 
buildprotected abstract SuggestionSearchContext.SuggestionContext build(SearchExecutionContext context) throws IOException - Throws:
- IOException
 
- 
populateCommonFieldsprotected void populateCommonFields(SearchExecutionContext context, SuggestionSearchContext.SuggestionContext suggestionContext) Transfers the text, prefix, regex, analyzer, field, size and shard size settings from the originalSuggestionBuilderto the targetSuggestionSearchContext.SuggestionContext
- 
equals
- 
doEqualsIndicates whether some otherSuggestionBuilderof the same type is "equal to" this one.
- 
hashCodepublic final int hashCode()
- 
doHashCodeprotected abstract int doHashCode()HashCode for the subclass ofSuggestionBuilderto implement.
 
-