Package org.elasticsearch.search.suggest
Class SuggestionBuilder<T extends SuggestionBuilder<T>>
- java.lang.Object
-
- org.elasticsearch.search.suggest.SuggestionBuilder<T>
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentFragment
- Direct Known Subclasses:
CompletionSuggestionBuilder,PhraseSuggestionBuilder,TermSuggestionBuilder
public abstract class SuggestionBuilder<T extends SuggestionBuilder<T>> extends Object implements NamedWriteable, ToXContentFragment
Base class for the different suggestion implementations.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description protected Stringanalyzerprotected static ParseFieldANALYZER_FIELDprotected Stringfieldprotected static ParseFieldFIELDNAME_FIELDprotected Stringprefixprotected static ParseFieldPREFIX_FIELDprotected Stringregexprotected static ParseFieldREGEX_FIELDprotected IntegershardSizeprotected static ParseFieldSHARDSIZE_FIELDprotected Integersizeprotected static ParseFieldSIZE_FIELDprotected Stringtextprotected static ParseFieldTEXT_FIELD-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSuggestionBuilder(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.protectedSuggestionBuilder(StreamInput in)Read from a stream.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Stringanalyzer()get theanalyzer()parameterTanalyzer(String analyzer)Sets the analyzer to analyse to suggest text with.protected abstract SuggestionSearchContext.SuggestionContextbuild(QueryShardContext context)protected abstract booleandoEquals(T other)Indicates whether some otherSuggestionBuilderof the same type is "equal to" this one.protected abstract intdoHashCode()HashCode for the subclass ofSuggestionBuilderto implement.protected abstract voiddoWriteTo(StreamOutput out)booleanequals(Object obj)Stringfield()get thefield()parameterinthashCode()protected abstract XContentBuilderinnerToXContent(XContentBuilder builder, ToXContent.Params params)protected voidpopulateCommonFields(MapperService mapperService, SuggestionSearchContext.SuggestionContext suggestionContext)Transfers the text, prefix, regex, analyzer, field, size and shard size settings from the originalSuggestionBuilderto the targetSuggestionSearchContext.SuggestionContextStringprefix()get the prefix for this suggestionprotected Tprefix(String prefix)Stringregex()get the regex for this suggestionprotected Tregex(String regex)IntegershardSize()get theshardSize()parameterTshardSize(Integer shardSize)Sets the maximum number of suggested term to be retrieved from each individual shard.Integersize()get thesize()parameterTsize(int size)Sets the maximum suggestions to be returned per suggest text term.Stringtext()get the text for this suggestionTtext(String text)Same as inSuggestBuilder.setGlobalText(String), but in the suggestion scope.XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable
getWriteableName
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
field
protected final String field
-
text
protected String text
-
prefix
protected String prefix
-
regex
protected String regex
-
analyzer
protected String analyzer
-
size
protected Integer size
-
shardSize
protected Integer shardSize
-
TEXT_FIELD
protected static final ParseField TEXT_FIELD
-
PREFIX_FIELD
protected static final ParseField PREFIX_FIELD
-
REGEX_FIELD
protected static final ParseField REGEX_FIELD
-
FIELDNAME_FIELD
protected static final ParseField FIELDNAME_FIELD
-
ANALYZER_FIELD
protected static final ParseField ANALYZER_FIELD
-
SIZE_FIELD
protected static final ParseField SIZE_FIELD
-
SHARDSIZE_FIELD
protected static final ParseField SHARDSIZE_FIELD
-
-
Constructor Detail
-
SuggestionBuilder
protected SuggestionBuilder(String field)
Creates a new suggestion.- Parameters:
field- field to execute suggestions on
-
SuggestionBuilder
protected SuggestionBuilder(String field, SuggestionBuilder<?> in)
internal copy constructor that copies over all class fields from second SuggestionBuilder except field name.
-
SuggestionBuilder
protected SuggestionBuilder(StreamInput in) throws IOException
Read from a stream.- Throws:
IOException
-
-
Method Detail
-
writeTo
public final void writeTo(StreamOutput out) throws IOException
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
doWriteTo
protected abstract void doWriteTo(StreamOutput out) throws IOException
- Throws:
IOException
-
text
public T text(String text)
Same as inSuggestBuilder.setGlobalText(String), but in the suggestion scope.
-
text
public String text()
get the text for this suggestion
-
prefix
public String prefix()
get the prefix for this suggestion
-
regex
public String regex()
get the regex for this suggestion
-
analyzer
public T analyzer(String analyzer)
Sets the analyzer to analyse to suggest text with. Defaults to the search analyzer of the suggest field.
-
analyzer
public String analyzer()
get theanalyzer()parameter
-
size
public T size(int size)
Sets the maximum suggestions to be returned per suggest text term.
-
shardSize
public T shardSize(Integer shardSize)
Sets 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.
-
shardSize
public Integer shardSize()
get theshardSize()parameter
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
innerToXContent
protected abstract XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
- Throws:
IOException
-
build
protected abstract SuggestionSearchContext.SuggestionContext build(QueryShardContext context) throws IOException
- Throws:
IOException
-
populateCommonFields
protected void populateCommonFields(MapperService mapperService, SuggestionSearchContext.SuggestionContext suggestionContext)
Transfers the text, prefix, regex, analyzer, field, size and shard size settings from the originalSuggestionBuilderto the targetSuggestionSearchContext.SuggestionContext
-
doEquals
protected abstract boolean doEquals(T other)
Indicates whether some otherSuggestionBuilderof the same type is "equal to" this one.
-
doHashCode
protected abstract int doHashCode()
HashCode for the subclass ofSuggestionBuilderto implement.
-
-