Class DirectCandidateGeneratorBuilder

All Implemented Interfaces:
Writeable, ToXContent, ToXContentObject, PhraseSuggestionBuilder.CandidateGenerator

public final class DirectCandidateGeneratorBuilder
extends java.lang.Object
implements PhraseSuggestionBuilder.CandidateGenerator
  • Field Details

  • Constructor Details

  • 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
    • suggestMode

      public DirectCandidateGeneratorBuilder suggestMode​(java.lang.String suggestMode)
      The global suggest mode controls what suggested terms are included or controls for what suggest text tokens, terms should be suggested for. Three possible values can be specified:
      1. missing - Only suggest terms in the suggest text that aren't in the index. This is the default.
      2. popular - Only suggest terms that occur in more docs then the original suggest text term.
      3. always - Suggest any matching suggest terms based on tokens in the suggest text.
    • accuracy

      public DirectCandidateGeneratorBuilder accuracy​(float accuracy)
      Sets how similar the suggested terms at least need to be compared to the original suggest text tokens. A value between 0 and 1 can be specified. This value will be compared to the string distance result of each candidate spelling correction.

      Default is 0.5

    • size

      public DirectCandidateGeneratorBuilder size​(int size)
      Sets the maximum suggestions to be returned per suggest text term.
    • sort

      public DirectCandidateGeneratorBuilder sort​(java.lang.String sort)
      Sets how to sort the suggest terms per suggest text token. Two possible values:
      1. score - Sort should first be based on score, then document frequency and then the term itself.
      2. frequency - Sort should first be based on document frequency, then score and then the term itself.

      What the score is depends on the suggester being used.

    • stringDistance

      public DirectCandidateGeneratorBuilder stringDistance​(java.lang.String stringDistance)
      Sets what string distance implementation to use for comparing how similar suggested terms are. Four possible values can be specified:
      1. internal - This is the default and is based on damerau_levenshtein, but highly optimized for comparing string distance for terms inside the index.
      2. damerau_levenshtein - String distance algorithm based on Damerau-Levenshtein algorithm.
      3. levenshtein - String distance algorithm based on Levenshtein edit distance algorithm.
      4. jaro_winkler - String distance algorithm based on Jaro-Winkler algorithm.
      5. ngram - String distance algorithm based on character n-grams.
    • maxEdits

      public DirectCandidateGeneratorBuilder maxEdits​(java.lang.Integer maxEdits)
      Sets the maximum edit distance candidate suggestions can have in order to be considered as a suggestion. Can only be a value between 1 and 2. Any other value result in an bad request error being thrown. Defaults to 2.
    • maxInspections

      public DirectCandidateGeneratorBuilder maxInspections​(java.lang.Integer maxInspections)
      A factor that is used to multiply with the size in order to inspect more candidate suggestions. Can improve accuracy at the cost of performance. Defaults to 5.
    • maxTermFreq

      public DirectCandidateGeneratorBuilder maxTermFreq​(float maxTermFreq)
      Sets a maximum threshold in number of documents a suggest text token can exist in order to be corrected. Can be a relative percentage number (e.g 0.4) or an absolute number to represent document frequencies. If an value higher than 1 is specified then fractional can not be specified. Defaults to 0.01.

      This can be used to exclude high frequency terms from being suggested. High frequency terms are usually spelled correctly on top of this this also improves the suggest performance.

    • prefixLength

      public DirectCandidateGeneratorBuilder prefixLength​(int prefixLength)
      Sets the number of minimal prefix characters that must match in order be a candidate suggestion. Defaults to 1. Increasing this number improves suggest performance. Usually misspellings don't occur in the beginning of terms.
    • minWordLength

      public DirectCandidateGeneratorBuilder minWordLength​(int minWordLength)
      The minimum length a suggest text term must have in order to be corrected. Defaults to 4.
    • minDocFreq

      public DirectCandidateGeneratorBuilder minDocFreq​(float minDocFreq)
      Sets a minimal threshold in number of documents a suggested term should appear in. This can be specified as an absolute number or as a relative percentage of number of documents. This can improve quality by only suggesting high frequency terms. Defaults to 0f and is not enabled. If a value higher than 1 is specified then the number cannot be fractional.
    • preFilter

      public DirectCandidateGeneratorBuilder preFilter​(java.lang.String preFilter)
      Sets a filter (analyzer) that is applied to each of the tokens passed to this candidate generator. This filter is applied to the original token before candidates are generated.
    • postFilter

      public DirectCandidateGeneratorBuilder postFilter​(java.lang.String postFilter)
      Sets a filter (analyzer) that is applied to each of the generated tokens before they are passed to the actual phrase scorer.
    • getType

      public java.lang.String getType()
      gets the type identifier of this PhraseSuggestionBuilder.CandidateGenerator
      Specified by:
      getType in interface PhraseSuggestionBuilder.CandidateGenerator
    • toXContent

      public XContentBuilder toXContent​(XContentBuilder builder, ToXContent.Params params) throws
      Specified by:
      toXContent in interface ToXContent
    • build

      public build​(MapperService mapperService) throws
      Specified by:
      build in interface PhraseSuggestionBuilder.CandidateGenerator
    • toString

      public java.lang.String toString()
      toString in class java.lang.Object
    • hashCode

      public int hashCode()
      hashCode in class java.lang.Object
    • equals

      public boolean equals​(java.lang.Object obj)
      equals in class java.lang.Object