Class PhraseSuggestionBuilder

org.elasticsearch.search.suggest.SuggestionBuilder<PhraseSuggestionBuilder>
org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder
All Implemented Interfaces:
NamedWriteable, Writeable, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment

public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionBuilder>
Defines the actual suggest command for phrase suggestions ( phrase).
  • Field Details

    • SUGGESTION_NAME

      public static final  SUGGESTION_NAME
      See Also:
      Constant Field Values
    • MAXERRORS_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField MAXERRORS_FIELD
    • RWE_LIKELIHOOD_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField RWE_LIKELIHOOD_FIELD
    • SEPARATOR_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SEPARATOR_FIELD
    • CONFIDENCE_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField CONFIDENCE_FIELD
    • GRAMSIZE_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField GRAMSIZE_FIELD
    • SMOOTHING_MODEL_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField SMOOTHING_MODEL_FIELD
    • FORCE_UNIGRAM_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField FORCE_UNIGRAM_FIELD
    • TOKEN_LIMIT_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField TOKEN_LIMIT_FIELD
    • HIGHLIGHT_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField HIGHLIGHT_FIELD
    • PRE_TAG_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField PRE_TAG_FIELD
    • POST_TAG_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField POST_TAG_FIELD
    • COLLATE_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField COLLATE_FIELD
    • COLLATE_QUERY_FIELD

      protected static final org.elasticsearch.common.xcontent.ParseField COLLATE_QUERY_FIELD
    • COLLATE_QUERY_PARAMS

      protected static final org.elasticsearch.common.xcontent.ParseField COLLATE_QUERY_PARAMS
    • COLLATE_QUERY_PRUNE

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

    • PhraseSuggestionBuilder

      public PhraseSuggestionBuilder( field)
    • PhraseSuggestionBuilder

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

    • doWriteTo

      public void doWriteTo(StreamOutput out) throws
      Specified by:
      doWriteTo in class SuggestionBuilder<PhraseSuggestionBuilder>
      Throws:
    • gramSize

      public PhraseSuggestionBuilder gramSize(int gramSize)
      Sets the gram size for the n-gram model used for this suggester. The default value is 1 corresponding to unigrams. Use 2 for bigrams and 3 for trigrams.
    • gramSize

      public  gramSize()
      get the gramSize(int) parameter
    • maxErrors

      public PhraseSuggestionBuilder maxErrors(float maxErrors)
      Sets the maximum percentage of the terms that at most considered to be misspellings in order to form a correction. This method accepts a float value in the range [0..1) as a fraction of the actual query terms a number &gt;=1 as an absolute number of query terms. The default is set to 1.0 which corresponds to that only corrections with at most 1 misspelled term are returned.
    • maxErrors

      public  maxErrors()
      get the maxErrors setting
    • separator

      public  separator)
      Sets the separator that is used to separate terms in the bigram field. If not set the whitespace character is used as a separator.
    • separator

      public  separator()
      get the separator that is used to separate terms in the bigram field.
    • realWordErrorLikelihood

      public PhraseSuggestionBuilder realWordErrorLikelihood(float realWordErrorLikelihood)
      Sets the likelihood of a term being a misspelled even if the term exists in the dictionary. The default it 0.95 corresponding to 5% or the real words are misspelled.
    • realWordErrorLikelihood

      public  realWordErrorLikelihood()
    • confidence

      public PhraseSuggestionBuilder confidence(float confidence)
      Sets the confidence level for this suggester. The confidence level defines a factor applied to the input phrases score which is used as a threshold for other suggest candidates. Only candidates that score higher than the threshold will be included in the result. For instance a confidence level of 1.0 will only return suggestions that score higher than the input phrase. If set to 0.0 the top N candidates are returned. The default is 1.0
    • confidence

      public  confidence()
      get the confidence() parameter
    • addCandidateGenerator

      public PhraseSuggestionBuilder addCandidateGenerator(PhraseSuggestionBuilder.CandidateGenerator generator)
      Adds a PhraseSuggestionBuilder.CandidateGenerator to this suggester. The PhraseSuggestionBuilder.CandidateGenerator is used to draw candidates for each individual phrase term before the candidates are scored.
    • clearCandidateGenerators

      public PhraseSuggestionBuilder clearCandidateGenerators()
      Clear the candidate generators.
    • forceUnigrams

      public PhraseSuggestionBuilder forceUnigrams(boolean forceUnigrams)
      If set to true the phrase suggester will fail if the analyzer only produces ngrams. the default it true.
    • forceUnigrams

      public  forceUnigrams()
      get the setting for forceUnigrams()
    • smoothingModel

      public PhraseSuggestionBuilder smoothingModel(SmoothingModel model)
      Sets an explicit smoothing model used for this suggester. The default is StupidBackoff.
    • smoothingModel

      public SmoothingModel smoothingModel()
    • tokenLimit

      public PhraseSuggestionBuilder tokenLimit(int tokenLimit)
    • tokenLimit

      public  tokenLimit()
      get the tokenLimit(int) parameter
    • highlight

      public  preTag,  postTag)
      Setup highlighting for suggestions. If this is called a highlight field is returned with suggestions wrapping changed tokens with preTag and postTag.
    • preTag

      public  preTag()
      get the pre-tag for the highlighter set with highlight(String, String)
    • postTag

      public  postTag()
      get the post-tag for the highlighter set with highlight(String, String)
    • collateQuery

      public  collateQuery)
      Sets a query used for filtering out suggested phrases (collation).
    • collateQuery

      public PhraseSuggestionBuilder collateQuery(Script collateQueryTemplate)
      Sets a query used for filtering out suggested phrases (collation).
    • collateQuery

      public Script collateQuery()
      gets the query used for filtering out suggested phrases (collation).
    • collateParams

      public <,​> collateParams)
      Adds additional parameters for collate scripts. Previously added parameters on the same builder will be overwritten.
    • collateParams

      public <,​> collateParams()
      gets additional params for collate script
    • collatePrune

      public PhraseSuggestionBuilder collatePrune(boolean collatePrune)
      Sets whether to prune suggestions after collation
    • collatePrune

      public  collatePrune()
      Gets whether to prune suggestions after collation
    • innerToXContent

      public org.elasticsearch.common.xcontent.XContentBuilder innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws
      Specified by:
      innerToXContent in class SuggestionBuilder<PhraseSuggestionBuilder>
      Throws:
    • fromXContent

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

      Specified by:
      build in class SuggestionBuilder<PhraseSuggestionBuilder>
      Throws:
    • getWriteableName

      public  getWriteableName()
      Description copied from interface: NamedWriteable
      Returns the name of the writeable object
    • doEquals

      protected boolean doEquals(PhraseSuggestionBuilder other)
      Description copied from class: SuggestionBuilder
      Indicates whether some other SuggestionBuilder of the same type is "equal to" this one.
      Specified by:
      doEquals in class SuggestionBuilder<PhraseSuggestionBuilder>
    • doHashCode

      protected int doHashCode()
      Description copied from class: SuggestionBuilder
      HashCode for the subclass of SuggestionBuilder to implement.
      Specified by:
      doHashCode in class SuggestionBuilder<PhraseSuggestionBuilder>