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>, NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment
Direct Known Subclasses:
CompletionSuggestion, PhraseSuggestion, TermSuggestion
Enclosing class:
Suggest

public abstract static class Suggest.Suggestion<T extends Suggest.Suggestion.Entry>
extends java.lang.Object
implements java.lang.Iterable<T>, NamedWriteable, org.elasticsearch.common.xcontent.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

    org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.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 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
    Constructor Description
    Suggestion​(java.lang.String name, int size)  
    Suggestion​(StreamInput in)  
  • Method Summary

    Modifier and Type Method Description
    void addTerm​(T entry)  
    boolean equals​(java.lang.Object other)  
    static Suggest.Suggestion<? extends Suggest.Suggestion.Entry<? extends Suggest.Suggestion.Entry.Option>> fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser)  
    java.util.List<T> getEntries()  
    java.lang.String getName()  
    int getSize()  
    abstract java.lang.String getWriteableName()
    Returns the name of the writeable object
    int getWriteableType()
    Deprecated.
    int hashCode()  
    java.util.Iterator<T> iterator()  
    protected abstract T newEntry​(StreamInput in)  
    protected static <E extends Suggest.Suggestion.Entry<?>>
    void
    parseEntries​(org.elasticsearch.common.xcontent.XContentParser parser, Suggest.Suggestion<E> suggestion, org.elasticsearch.common.CheckedFunction<org.elasticsearch.common.xcontent.XContentParser,​E,​java.io.IOException> entryParser)  
    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()  
    org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)  
    void trim()
    Trims the number of options per suggest text term to the requested size.
    void writeTo​(StreamOutput out)
    Write this into the StreamOutput.

    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 Details

    • TYPE

      public static final int TYPE
      See Also:
      Constant Field Values
    • name

      protected final java.lang.String name
    • size

      protected final int size
    • entries

      protected final java.util.List<T extends Suggest.Suggestion.Entry> entries
  • Constructor Details

    • Suggestion

      public Suggestion​(java.lang.String name, int size)
    • Suggestion

      public Suggestion​(StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException
  • Method Details

    • 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 java.util.Iterator<T> iterator()
      Specified by:
      iterator in interface java.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.
    • newEntry

      protected abstract T newEntry​(StreamInput in) throws java.io.IOException
      Throws:
      java.io.IOException
    • writeTo

      public void writeTo​(StreamOutput out) throws java.io.IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      java.io.IOException
    • getWriteableName

      public abstract java.lang.String getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object
      Specified by:
      getWriteableName in interface NamedWriteable
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException
    • equals

      public boolean equals​(java.lang.Object other)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • fromXContent

      public static Suggest.Suggestion<? extends Suggest.Suggestion.Entry<? extends Suggest.Suggestion.Entry.Option>> fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException
      Throws:
      java.io.IOException
    • parseEntries

      protected static <E extends Suggest.Suggestion.Entry<?>> void parseEntries​(org.elasticsearch.common.xcontent.XContentParser parser, Suggest.Suggestion<E> suggestion, org.elasticsearch.common.CheckedFunction<org.elasticsearch.common.xcontent.XContentParser,​E,​java.io.IOException> entryParser) throws java.io.IOException
      Throws:
      java.io.IOException