Class SuggestBuilder

org.elasticsearch.search.suggest.SuggestBuilder
All Implemented Interfaces:
Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject

public class SuggestBuilder extends implements Writeable, org.elasticsearch.common.xcontent.ToXContentObject
Defines how to perform suggesting. This builders allows a number of global options to be specified and an arbitrary number of 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.

  • Nested Class Summary

    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 static org.elasticsearch.common.xcontent.ParseField
     

    Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent

    EMPTY_PARAMS
  • Constructor Summary

    Constructors
    Constructor
    Description
    Build an empty SuggestBuilder.
    Read from a stream.
  • Method Summary

    Modifier and Type
    Method
    Description
     name, SuggestionBuilder<?> suggestion)
    Adds an SuggestionBuilder instance under a user defined name.
     
    boolean
     other)
     
    fromXContent​(org.elasticsearch.common.xcontent.XContentParser parser)
     
    Gets the global suggest text
    Get all the Suggestions that were added to the global SuggestBuilder, together with their names
    int
     
     globalText)
    Sets the text to provide suggestions for.
     
    org.elasticsearch.common.xcontent.XContentBuilder
    toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
     
    void
    Write this into the StreamOutput.

    Methods inherited from class java.lang.

    , , , , , , ,

    Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject

    isFragment
  • Field Details

    • GLOBAL_TEXT_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField GLOBAL_TEXT_FIELD
  • Constructor Details

    • SuggestBuilder

      public SuggestBuilder()
      Build an empty SuggestBuilder.
    • SuggestBuilder

      public SuggestBuilder(StreamInput in) throws
      Read from a stream.
      Throws:
  • Method Details

    • writeTo

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

      public SuggestBuilder setGlobalText(@Nullable  globalText)
      Sets the text to provide suggestions for. The suggest text is a required option that needs to be set either via this setter or via the 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.

    • getGlobalText

      @Nullable public  getGlobalText()
      Gets the global suggest text
    • addSuggestion

      public  name, SuggestionBuilder<?> suggestion)
      Adds an SuggestionBuilder instance under a user defined name. The order in which the Suggestions are added, is the same as in the response.
      Throws:
      - if two suggestions added have the same name
    • getSuggestions

      public <,​SuggestionBuilder<?>> getSuggestions()
      Get all the Suggestions that were added to the global SuggestBuilder, together with their names
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
    • fromXContent

      public static SuggestBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws
      Throws:
    • build

      public SuggestionSearchContext build(SearchExecutionContext context) throws
      Throws:
    • equals

      public boolean equals( other)
      Overrides:
       in class 
    • hashCode

      public int hashCode()
      Overrides:
       in class 
    • toString

      public  toString()
      Overrides:
       in class