Class PhraseSuggestionBuilder
java.lang.Object
org.elasticsearch.search.suggest.SuggestionBuilder<PhraseSuggestionBuilder>
org.elasticsearch.search.suggest.phrase.PhraseSuggestionBuilder
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentFragment
public class PhraseSuggestionBuilder extends SuggestionBuilder<PhraseSuggestionBuilder>
Defines the actual suggest command for phrase suggestions (
phrase).-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfacePhraseSuggestionBuilder.CandidateGeneratorPhraseSuggestionBuilder.CandidateGeneratorinterface.Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested 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 ParseFieldCOLLATE_FIELDprotected static ParseFieldCOLLATE_QUERY_FIELDprotected static ParseFieldCOLLATE_QUERY_PARAMSprotected static ParseFieldCOLLATE_QUERY_PRUNEprotected static ParseFieldCONFIDENCE_FIELDprotected static ParseFieldFORCE_UNIGRAM_FIELDprotected static ParseFieldGRAMSIZE_FIELDprotected static ParseFieldHIGHLIGHT_FIELDprotected static ParseFieldMAXERRORS_FIELDprotected static ParseFieldPOST_TAG_FIELDprotected static ParseFieldPRE_TAG_FIELDprotected static ParseFieldRWE_LIKELIHOOD_FIELDprotected static ParseFieldSEPARATOR_FIELDprotected static ParseFieldSMOOTHING_MODEL_FIELDstatic java.lang.StringSUGGESTION_NAMEprotected static ParseFieldTOKEN_LIMIT_FIELDFields inherited from class org.elasticsearch.search.suggest.SuggestionBuilder
analyzer, ANALYZER_FIELD, field, FIELDNAME_FIELD, prefix, PREFIX_FIELD, regex, REGEX_FIELD, shardSize, SHARDSIZE_FIELD, size, SIZE_FIELD, text, TEXT_FIELD -
Constructor Summary
Constructors Constructor Description PhraseSuggestionBuilder(java.lang.String field)PhraseSuggestionBuilder(StreamInput in)Read from a stream. -
Method Summary
Modifier and Type Method Description PhraseSuggestionBuilderaddCandidateGenerator(PhraseSuggestionBuilder.CandidateGenerator generator)Adds aPhraseSuggestionBuilder.CandidateGeneratorto this suggester.SuggestionSearchContext.SuggestionContextbuild(QueryShardContext context)PhraseSuggestionBuilderclearCandidateGenerators()Clear the candidate generators.java.util.Map<java.lang.String,java.lang.Object>collateParams()gets additional params for collate scriptPhraseSuggestionBuildercollateParams(java.util.Map<java.lang.String,java.lang.Object> collateParams)Adds additional parameters for collate scripts.java.lang.BooleancollatePrune()Gets whether to prune suggestions after collationPhraseSuggestionBuildercollatePrune(boolean collatePrune)Sets whether to prune suggestions after collationScriptcollateQuery()gets the query used for filtering out suggested phrases (collation).PhraseSuggestionBuildercollateQuery(java.lang.String collateQuery)Sets a query used for filtering out suggested phrases (collation).PhraseSuggestionBuildercollateQuery(Script collateQueryTemplate)Sets a query used for filtering out suggested phrases (collation).java.lang.Floatconfidence()get theconfidence()parameterPhraseSuggestionBuilderconfidence(float confidence)Sets the confidence level for this suggester.protected booleandoEquals(PhraseSuggestionBuilder other)Indicates whether some otherSuggestionBuilderof the same type is "equal to" this one.protected intdoHashCode()HashCode for the subclass ofSuggestionBuilderto implement.voiddoWriteTo(StreamOutput out)java.lang.BooleanforceUnigrams()get the setting forforceUnigrams()PhraseSuggestionBuilderforceUnigrams(boolean forceUnigrams)If set totruethe phrase suggester will fail if the analyzer only produces ngrams.static PhraseSuggestionBuilderfromXContent(XContentParser parser)java.lang.StringgetWriteableName()Returns the name of the writeable objectjava.lang.IntegergramSize()get thegramSize(int)parameterPhraseSuggestionBuildergramSize(int gramSize)Sets the gram size for the n-gram model used for this suggester.PhraseSuggestionBuilderhighlight(java.lang.String preTag, java.lang.String postTag)Setup highlighting for suggestions.XContentBuilderinnerToXContent(XContentBuilder builder, ToXContent.Params params)java.lang.FloatmaxErrors()get the maxErrors settingPhraseSuggestionBuildermaxErrors(float maxErrors)Sets the maximum percentage of the terms that at most considered to be misspellings in order to form a correction.java.lang.StringpostTag()get the post-tag for the highlighter set withhighlight(String, String)java.lang.StringpreTag()get the pre-tag for the highlighter set withhighlight(String, String)java.lang.FloatrealWordErrorLikelihood()get therealWordErrorLikelihood(float)parameterPhraseSuggestionBuilderrealWordErrorLikelihood(float realWordErrorLikelihood)Sets the likelihood of a term being a misspelled even if the term exists in the dictionary.java.lang.Stringseparator()get the separator that is used to separate terms in the bigram field.PhraseSuggestionBuilderseparator(java.lang.String separator)Sets the separator that is used to separate terms in the bigram field.SmoothingModelsmoothingModel()Gets theSmoothingModelPhraseSuggestionBuildersmoothingModel(SmoothingModel model)Sets an explicit smoothing model used for this suggester.java.lang.IntegertokenLimit()get thetokenLimit(int)parameterPhraseSuggestionBuildertokenLimit(int tokenLimit)Methods inherited from class org.elasticsearch.search.suggest.SuggestionBuilder
analyzer, analyzer, equals, field, hashCode, populateCommonFields, prefix, prefix, regex, regex, shardSize, shardSize, size, size, text, text, toXContent, writeTo
-
Field Details
-
SUGGESTION_NAME
public static final java.lang.String SUGGESTION_NAME- See Also:
- Constant Field Values
-
MAXERRORS_FIELD
-
RWE_LIKELIHOOD_FIELD
-
SEPARATOR_FIELD
-
CONFIDENCE_FIELD
-
GRAMSIZE_FIELD
-
SMOOTHING_MODEL_FIELD
-
FORCE_UNIGRAM_FIELD
-
TOKEN_LIMIT_FIELD
-
HIGHLIGHT_FIELD
-
PRE_TAG_FIELD
-
POST_TAG_FIELD
-
COLLATE_FIELD
-
COLLATE_QUERY_FIELD
-
COLLATE_QUERY_PARAMS
-
COLLATE_QUERY_PRUNE
-
-
Constructor Details
-
PhraseSuggestionBuilder
public PhraseSuggestionBuilder(java.lang.String field) -
PhraseSuggestionBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classSuggestionBuilder<PhraseSuggestionBuilder>- Throws:
java.io.IOException
-
gramSize
Sets the gram size for the n-gram model used for this suggester. The default value is1corresponding tounigrams. Use2forbigramsand3fortrigrams. -
gramSize
public java.lang.Integer gramSize()get thegramSize(int)parameter -
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>=1as an absolute number of query terms. The default is set to1.0which corresponds to that only corrections with at most 1 misspelled term are returned. -
maxErrors
public java.lang.Float maxErrors()get the maxErrors setting -
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 java.lang.String separator()get the separator that is used to separate terms in the bigram field. -
realWordErrorLikelihood
Sets the likelihood of a term being a misspelled even if the term exists in the dictionary. The default it0.95corresponding to 5% or the real words are misspelled. -
realWordErrorLikelihood
public java.lang.Float realWordErrorLikelihood()get therealWordErrorLikelihood(float)parameter -
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 of1.0will only return suggestions that score higher than the input phrase. If set to0.0the top N candidates are returned. The default is1.0 -
confidence
public java.lang.Float confidence()get theconfidence()parameter -
addCandidateGenerator
public PhraseSuggestionBuilder addCandidateGenerator(PhraseSuggestionBuilder.CandidateGenerator generator)Adds aPhraseSuggestionBuilder.CandidateGeneratorto this suggester. ThePhraseSuggestionBuilder.CandidateGeneratoris used to draw candidates for each individual phrase term before the candidates are scored. -
clearCandidateGenerators
Clear the candidate generators. -
forceUnigrams
If set totruethe phrase suggester will fail if the analyzer only produces ngrams. the default ittrue. -
forceUnigrams
public java.lang.Boolean forceUnigrams()get the setting forforceUnigrams() -
smoothingModel
Sets an explicit smoothing model used for this suggester. The default isStupidBackoff. -
smoothingModel
Gets theSmoothingModel -
tokenLimit
-
tokenLimit
public java.lang.Integer tokenLimit()get thetokenLimit(int)parameter -
highlight
Setup highlighting for suggestions. If this is called a highlight field is returned with suggestions wrapping changed tokens with preTag and postTag. -
preTag
public java.lang.String preTag()get the pre-tag for the highlighter set withhighlight(String, String) -
postTag
public java.lang.String postTag()get the post-tag for the highlighter set withhighlight(String, String) -
collateQuery
Sets a query used for filtering out suggested phrases (collation). -
collateQuery
Sets a query used for filtering out suggested phrases (collation). -
collateQuery
gets the query used for filtering out suggested phrases (collation). -
collateParams
public PhraseSuggestionBuilder collateParams(java.util.Map<java.lang.String,java.lang.Object> collateParams)Adds additional parameters for collate scripts. Previously added parameters on the same builder will be overwritten. -
collateParams
public java.util.Map<java.lang.String,java.lang.Object> collateParams()gets additional params for collate script -
collatePrune
Sets whether to prune suggestions after collation -
collatePrune
public java.lang.Boolean collatePrune()Gets whether to prune suggestions after collation -
innerToXContent
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException- Specified by:
innerToXContentin classSuggestionBuilder<PhraseSuggestionBuilder>- Throws:
java.io.IOException
-
fromXContent
public static PhraseSuggestionBuilder fromXContent(XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
build
public SuggestionSearchContext.SuggestionContext build(QueryShardContext context) throws java.io.IOException- Specified by:
buildin classSuggestionBuilder<PhraseSuggestionBuilder>- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()Description copied from interface:NamedWriteableReturns the name of the writeable object -
doEquals
Description copied from class:SuggestionBuilderIndicates whether some otherSuggestionBuilderof the same type is "equal to" this one.- Specified by:
doEqualsin classSuggestionBuilder<PhraseSuggestionBuilder>
-
doHashCode
protected int doHashCode()Description copied from class:SuggestionBuilderHashCode for the subclass ofSuggestionBuilderto implement.- Specified by:
doHashCodein classSuggestionBuilder<PhraseSuggestionBuilder>
-