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 class
Suggest.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>
entries
protected java.lang.String
name
protected int
size
static int
TYPE
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Suggestion()
Suggestion(java.lang.String name, int size)
-
Method Summary
Modifier and Type Method Description void
addTerm(T entry)
static Suggest.Suggestion<? extends Suggest.Suggestion.Entry<? extends Suggest.Suggestion.Entry.Option>>
fromXContent(XContentParser parser)
java.util.List<T>
getEntries()
java.lang.String
getName()
int
getSize()
protected java.lang.String
getType()
Returns a string representing the type of the suggestion.int
getWriteableType()
Returns a integer representing the type of the suggestion.protected void
innerReadFrom(StreamInput in)
void
innerWriteTo(StreamOutput out)
java.util.Iterator<T>
iterator()
protected T
newEntry()
protected static <E extends Suggest.Suggestion.Entry<?>>
voidparseEntries(XContentParser parser, Suggest.Suggestion<E> suggestion, CheckedFunction<XContentParser,E,java.io.IOException> entryParser)
void
readFrom(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()
XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
void
trim()
Trims the number of options per suggest text term to the requested size.void
writeTo(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:
iterator
in 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:Streamable
Set this object's fields from a StreamInput.- Specified by:
readFrom
in 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:Streamable
Write this object's fields to a StreamOutput.- Specified by:
writeTo
in 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:
toXContent
in 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
-
-