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 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
FieldsModifier and TypeFieldDescriptionprotected Stringprotected static org.elasticsearch.common.xcontent.ParseFieldprotected Stringprotected static org.elasticsearch.common.xcontent.ParseFieldprotected Stringprotected static org.elasticsearch.common.xcontent.ParseFieldprotected Stringprotected static org.elasticsearch.common.xcontent.ParseFieldprotected Integerprotected static org.elasticsearch.common.xcontent.ParseFieldprotected Integerprotected static org.elasticsearch.common.xcontent.ParseFieldprotected Stringprotected static org.elasticsearch.common.xcontent.ParseFieldFields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSuggestionBuilder(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 Summary
Modifier 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)booleanfield()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(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.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.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable
getWriteableNameMethods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Field Details
-
field
-
text
-
prefix
-
regex
-
analyzer
-
size
-
shardSize
-
TEXT_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField TEXT_FIELD -
PREFIX_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField PREFIX_FIELD -
REGEX_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField REGEX_FIELD -
FIELDNAME_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField FIELDNAME_FIELD -
ANALYZER_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField ANALYZER_FIELD -
SIZE_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField SIZE_FIELD -
SHARDSIZE_FIELD
protected static final org.elasticsearch.common.xcontent.ParseField SHARDSIZE_FIELD
-
-
Constructor Details
-
SuggestionBuilder
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:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
doWriteTo
- Throws:
IOException
-
text
Same as inSuggestBuilder.setGlobalText(String), but in the suggestion scope. -
text
get the text for this suggestion -
prefix
-
prefix
get the prefix for this suggestion -
regex
-
regex
get the regex for this suggestion -
field
get thefield()parameter -
analyzer
Sets the analyzer to analyse to suggest text with. Defaults to the search analyzer of the suggest field. -
analyzer
get theanalyzer()parameter -
size
Sets the maximum suggestions to be returned per suggest text term. -
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
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 IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
IOException
-
innerToXContent
protected abstract org.elasticsearch.common.xcontent.XContentBuilder innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Throws:
IOException
-
build
protected abstract SuggestionSearchContext.SuggestionContext build(SearchExecutionContext context) throws IOException- Throws:
IOException
-
populateCommonFields
protected 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
-
doEquals
Indicates whether some otherSuggestionBuilderof the same type is "equal to" this one. -
hashCode
public final int hashCode() -
doHashCode
protected abstract int doHashCode()HashCode for the subclass ofSuggestionBuilderto implement.
-