public class SuggestBuilder extends ToXContentToBytes implements Writeable
SuggestionBuilder
instances.
Suggesting works by suggesting terms/phrases that appear in the suggest text that are similar compared to the terms in provided text. These suggestions are based on several options described in this class.
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and Description |
---|---|
protected static ParseField |
GLOBAL_TEXT_FIELD |
EMPTY_PARAMS
Constructor and Description |
---|
SuggestBuilder()
Build an empty SuggestBuilder.
|
SuggestBuilder(StreamInput in)
Read from a stream.
|
Modifier and Type | Method and Description |
---|---|
SuggestBuilder |
addSuggestion(java.lang.String name,
SuggestionBuilder<?> suggestion)
Adds an
SuggestionBuilder instance under a user defined name. |
SuggestionSearchContext |
build(QueryShardContext context) |
boolean |
equals(java.lang.Object other) |
static SuggestBuilder |
fromXContent(QueryParseContext parseContext,
Suggesters suggesters) |
java.lang.String |
getGlobalText()
Gets the global suggest text
|
java.util.Map<java.lang.String,SuggestionBuilder<?>> |
getSuggestions()
Get all the
Suggestions that were added to the global SuggestBuilder ,
together with their names |
int |
hashCode() |
SuggestBuilder |
setGlobalText(java.lang.String globalText)
Sets the text to provide suggestions for.
|
XContentBuilder |
toXContent(XContentBuilder builder,
ToXContent.Params params) |
void |
writeTo(StreamOutput out)
Write this into the StreamOutput.
|
buildAsBytes, buildAsBytes, toString
protected static final ParseField GLOBAL_TEXT_FIELD
public SuggestBuilder()
public SuggestBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
public void writeTo(StreamOutput out) throws java.io.IOException
Writeable
public SuggestBuilder setGlobalText(@Nullable java.lang.String globalText)
SuggestionBuilder.text(String)
method.
The suggest text gets analyzed by the suggest analyzer or the suggest field search analyzer. For each analyzed token, suggested terms are suggested if possible.
@Nullable public java.lang.String getGlobalText()
public SuggestBuilder addSuggestion(java.lang.String name, SuggestionBuilder<?> suggestion)
SuggestionBuilder
instance under a user defined name.
The order in which the Suggestions
are added, is the same as in the response.java.lang.IllegalArgumentException
- if two suggestions added have the same namepublic java.util.Map<java.lang.String,SuggestionBuilder<?>> getSuggestions()
Suggestions
that were added to the global SuggestBuilder
,
together with their namespublic XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
toXContent
in interface ToXContent
java.io.IOException
public static SuggestBuilder fromXContent(QueryParseContext parseContext, Suggesters suggesters) throws java.io.IOException
java.io.IOException
public SuggestionSearchContext build(QueryShardContext context) throws java.io.IOException
java.io.IOException
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object