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,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentFragment
- Direct Known Subclasses:
CompletionSuggestionBuilder,PhraseSuggestionBuilder,TermSuggestionBuilder
public abstract class SuggestionBuilder<T extends SuggestionBuilder<T>> extends java.lang.Object implements NamedWriteable, org.elasticsearch.common.xcontent.ToXContentFragment
Base class for the different suggestion implementations.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested 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 java.lang.Stringanalyzerprotected static org.elasticsearch.common.ParseFieldANALYZER_FIELDprotected java.lang.Stringfieldprotected static org.elasticsearch.common.ParseFieldFIELDNAME_FIELDprotected java.lang.Stringprefixprotected static org.elasticsearch.common.ParseFieldPREFIX_FIELDprotected java.lang.Stringregexprotected static org.elasticsearch.common.ParseFieldREGEX_FIELDprotected java.lang.IntegershardSizeprotected static org.elasticsearch.common.ParseFieldSHARDSIZE_FIELDprotected java.lang.Integersizeprotected static org.elasticsearch.common.ParseFieldSIZE_FIELDprotected java.lang.Stringtextprotected static org.elasticsearch.common.ParseFieldTEXT_FIELD -
Constructor Summary
Constructors Modifier Constructor Description protectedSuggestionBuilder(java.lang.String field)Creates a new suggestion.protectedSuggestionBuilder(java.lang.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
Modifier and Type Method Description java.lang.Stringanalyzer()get theanalyzer()parameterTanalyzer(java.lang.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(java.lang.Object obj)java.lang.Stringfield()get thefield()parameterinthashCode()protected abstract org.elasticsearch.common.xcontent.XContentBuilderinnerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.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.SuggestionContextjava.lang.Stringprefix()get the prefix for this suggestionprotected Tprefix(java.lang.String prefix)java.lang.Stringregex()get the regex for this suggestionprotected Tregex(java.lang.String regex)java.lang.IntegershardSize()get theshardSize()parameterTshardSize(java.lang.Integer shardSize)Sets the maximum number of suggested term to be retrieved from each individual shard.java.lang.Integersize()get thesize()parameterTsize(int size)Sets the maximum suggestions to be returned per suggest text term.java.lang.Stringtext()get the text for this suggestionTtext(java.lang.String text)Same as inSuggestBuilder.setGlobalText(String), but in the suggestion scope.org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.
-
Field Details
-
field
protected final java.lang.String field -
text
protected java.lang.String text -
prefix
protected java.lang.String prefix -
regex
protected java.lang.String regex -
analyzer
protected java.lang.String analyzer -
size
protected java.lang.Integer size -
shardSize
protected java.lang.Integer shardSize -
TEXT_FIELD
protected static final org.elasticsearch.common.ParseField TEXT_FIELD -
PREFIX_FIELD
protected static final org.elasticsearch.common.ParseField PREFIX_FIELD -
REGEX_FIELD
protected static final org.elasticsearch.common.ParseField REGEX_FIELD -
FIELDNAME_FIELD
protected static final org.elasticsearch.common.ParseField FIELDNAME_FIELD -
ANALYZER_FIELD
protected static final org.elasticsearch.common.ParseField ANALYZER_FIELD -
SIZE_FIELD
protected static final org.elasticsearch.common.ParseField SIZE_FIELD -
SHARDSIZE_FIELD
protected static final org.elasticsearch.common.ParseField SHARDSIZE_FIELD
-
-
Constructor Details
-
SuggestionBuilder
protected SuggestionBuilder(java.lang.String field)Creates a new suggestion.- Parameters:
field- field to execute suggestions on
-
SuggestionBuilder
internal copy constructor that copies over all class fields from second SuggestionBuilder except field name. -
SuggestionBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput. -
doWriteTo
- Throws:
java.io.IOException
-
text
Same as inSuggestBuilder.setGlobalText(String), but in the suggestion scope. -
text
public java.lang.String text()get the text for this suggestion -
prefix
-
prefix
public java.lang.String prefix()get the prefix for this suggestion -
regex
-
regex
public java.lang.String regex()get the regex for this suggestion -
field
public java.lang.String field()get thefield()parameter -
analyzer
Sets the analyzer to analyse to suggest text with. Defaults to the search analyzer of the suggest field. -
analyzer
public java.lang.String analyzer()get theanalyzer()parameter -
size
Sets the maximum suggestions to be returned per suggest text term. -
size
public java.lang.Integer size()get thesize()parameter -
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 java.lang.Integer shardSize()get theshardSize()parameter -
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
innerToXContent
protected abstract org.elasticsearch.common.xcontent.XContentBuilder innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Throws:
java.io.IOException
-
build
protected abstract SuggestionSearchContext.SuggestionContext build(QueryShardContext context) throws java.io.IOException- Throws:
java.io.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 -
equals
public final boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
doEquals
Indicates whether some otherSuggestionBuilderof the same type is "equal to" this one. -
hashCode
public final int hashCode()- Overrides:
hashCodein classjava.lang.Object
-
doHashCode
protected abstract int doHashCode()HashCode for the subclass ofSuggestionBuilderto implement.
-