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:
Iterable<T>,NamedWriteable,Writeable,ToXContent,ToXContentFragment
- Direct Known Subclasses:
CompletionSuggestion,PhraseSuggestion,TermSuggestion
- Enclosing class:
- Suggest
public abstract static class Suggest.Suggestion<T extends Suggest.Suggestion.Entry> extends Object implements Iterable<T>, NamedWriteable, 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
-
Nested 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 List<T>entriesprotected Stringnameprotected intsizestatic intTYPE-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description Suggestion(String name, int size)Suggestion(StreamInput in)
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
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 final String name
-
size
protected final int size
-
entries
protected final List<T extends Suggest.Suggestion.Entry> entries
-
-
Constructor Detail
-
Suggestion
public Suggestion(String name, int size)
-
Suggestion
public Suggestion(StreamInput in) throws IOException
- Throws:
IOException
-
-
Method Detail
-
addTerm
public void addTerm(T entry)
-
getWriteableType
@Deprecated public int getWriteableType()
Deprecated.Returns a integer representing the type of the suggestion. This is used for internal serialization over the network. This class is now serialized as a NamedWriteable and this method only remains for backwards compatibility
-
iterator
public Iterator<T> iterator()
- Specified by:
iteratorin interfaceIterable<T extends Suggest.Suggestion.Entry>
-
getName
public 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(List<Suggest.Suggestion<T>> toReduce)
Merges the result of another suggestion into this suggestion. For internal usage.
-
sortComparator
protected 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.
-
newEntry
protected abstract T newEntry(StreamInput in) throws IOException
- Throws:
IOException
-
writeTo
public void writeTo(StreamOutput out) throws IOException
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
getWriteableName
public abstract String getWriteableName()
Description copied from interface:NamedWriteableReturns the name of the writeable object- Specified by:
getWriteableNamein interfaceNamedWriteable
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
- Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
fromXContent
public static Suggest.Suggestion<? extends Suggest.Suggestion.Entry<? extends Suggest.Suggestion.Entry.Option>> fromXContent(XContentParser parser) throws IOException
- Throws:
IOException
-
parseEntries
protected static <E extends Suggest.Suggestion.Entry<?>> void parseEntries(XContentParser parser, Suggest.Suggestion<E> suggestion, CheckedFunction<XContentParser,E,IOException> entryParser) throws IOException
- Throws:
IOException
-
-