Package org.elasticsearch.search.suggest
Class Suggest.Suggestion<T extends Suggest.Suggestion.Entry>
- java.lang.Object
-
- org.elasticsearch.search.suggest.Suggest.Suggestion<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>,Streamable,ToXContent,ToXContentFragment
- Direct Known Subclasses:
CompletionSuggestion,PhraseSuggestion,TermSuggestion
- Enclosing class:
- Suggest
public static class Suggest.Suggestion<T extends Suggest.Suggestion.Entry> extends java.lang.Object implements java.lang.Iterable<T>, Streamable, ToXContentFragment
The suggestion responses corresponding with the suggestions in the request.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSuggest.Suggestion.Entry<O extends Suggest.Suggestion.Entry.Option>Represents a part from the suggest text with suggested options.-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<T>entriesprotected java.lang.Stringnameprotected intsizestatic intTYPE-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSuggestion()Suggestion(java.lang.String name, int size)
-
Method Summary
Modifier and Type Method Description voidaddTerm(T entry)static Suggest.Suggestion<? extends Suggest.Suggestion.Entry<? extends Suggest.Suggestion.Entry.Option>>fromXContent(XContentParser parser)java.util.List<T>getEntries()java.lang.StringgetName()intgetSize()protected java.lang.StringgetType()Returns a string representing the type of the suggestion.intgetWriteableType()Returns a integer representing the type of the suggestion.protected voidinnerReadFrom(StreamInput in)voidinnerWriteTo(StreamOutput out)java.util.Iterator<T>iterator()protected TnewEntry()protected static <E extends Suggest.Suggestion.Entry<?>>
voidparseEntries(XContentParser parser, Suggest.Suggestion<E> suggestion, CheckedFunction<XContentParser,E,java.io.IOException> entryParser)voidreadFrom(StreamInput in)Set this object's fields from a StreamInput.Suggest.Suggestion<T>reduce(java.util.List<Suggest.Suggestion<T>> toReduce)Merges the result of another suggestion into this suggestion.protected java.util.Comparator<Suggest.Suggestion.Entry.Option>sortComparator()XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)voidtrim()Trims the number of options per suggest text term to the requested size.voidwriteTo(StreamOutput out)Write this object's fields to a StreamOutput.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
TYPE
public static final int TYPE
- See Also:
- Constant Field Values
-
name
protected java.lang.String name
-
size
protected int size
-
entries
protected final java.util.List<T extends Suggest.Suggestion.Entry> entries
-
-
Method Detail
-
addTerm
public void addTerm(T entry)
-
getWriteableType
public int getWriteableType()
Returns a integer representing the type of the suggestion. This is used for internal serialization over the network.
-
getType
protected java.lang.String getType()
Returns a string representing the type of the suggestion. This type is added to the suggestion name in the XContent response, so that it can later be used by REST clients to determine the internal type of the suggestion.
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T extends Suggest.Suggestion.Entry>
-
getEntries
public java.util.List<T> getEntries()
- Returns:
- The entries for this suggestion.
-
getName
public java.lang.String getName()
- Returns:
- The name of the suggestion as is defined in the request.
-
getSize
public int getSize()
- Returns:
- The number of requested suggestion option size
-
reduce
public Suggest.Suggestion<T> reduce(java.util.List<Suggest.Suggestion<T>> toReduce)
Merges the result of another suggestion into this suggestion. For internal usage.
-
sortComparator
protected java.util.Comparator<Suggest.Suggestion.Entry.Option> sortComparator()
-
trim
public void trim()
Trims the number of options per suggest text term to the requested size. For internal usage.
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:StreamableSet this object's fields from a StreamInput.- Specified by:
readFromin interfaceStreamable- Throws:
java.io.IOException
-
newEntry
protected T newEntry()
-
innerReadFrom
protected void innerReadFrom(StreamInput in) throws java.io.IOException
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:StreamableWrite this object's fields to a StreamOutput.- Specified by:
writeToin interfaceStreamable- Throws:
java.io.IOException
-
innerWriteTo
public void innerWriteTo(StreamOutput out) throws java.io.IOException
- Throws:
java.io.IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
java.io.IOException
-
fromXContent
public static Suggest.Suggestion<? extends Suggest.Suggestion.Entry<? extends Suggest.Suggestion.Entry.Option>> fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
parseEntries
protected static <E extends Suggest.Suggestion.Entry<?>> void parseEntries(XContentParser parser, Suggest.Suggestion<E> suggestion, CheckedFunction<XContentParser,E,java.io.IOException> entryParser) throws java.io.IOException
- Throws:
java.io.IOException
-
-