Package org.elasticsearch.index.query
Class FuzzyQueryBuilder
java.lang.Object
org.elasticsearch.index.query.AbstractQueryBuilder<FuzzyQueryBuilder>
org.elasticsearch.index.query.FuzzyQueryBuilder
- All Implemented Interfaces:
NamedWriteable,Writeable,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.ToXContentObject,MultiTermQueryBuilder,QueryBuilder,Rewriteable<QueryBuilder>
public class FuzzyQueryBuilder extends AbstractQueryBuilder<FuzzyQueryBuilder> implements MultiTermQueryBuilder
A Query that does fuzzy matching for a specific value.
-
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.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 static FuzzinessDEFAULT_FUZZINESSDefault maximum edit distance.static intDEFAULT_MAX_EXPANSIONSDefault maximum number of terms that the fuzzy query will expand to.static intDEFAULT_PREFIX_LENGTHDefault number of initial characters which will not be “fuzzified”.static booleanDEFAULT_TRANSPOSITIONSDefault as to whether transpositions should be treated as a primitive edit operation, instead of classic Levenshtein algorithm.static java.lang.StringNAMEFields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName -
Constructor Summary
Constructors Constructor Description FuzzyQueryBuilder(java.lang.String fieldName, boolean value)Constructs a new fuzzy query.FuzzyQueryBuilder(java.lang.String fieldName, double value)Constructs a new fuzzy query.FuzzyQueryBuilder(java.lang.String fieldName, float value)Constructs a new fuzzy query.FuzzyQueryBuilder(java.lang.String fieldName, int value)Constructs a new fuzzy query.FuzzyQueryBuilder(java.lang.String fieldName, long value)Constructs a new fuzzy query.FuzzyQueryBuilder(java.lang.String fieldName, java.lang.Object value)Constructs a new fuzzy query.FuzzyQueryBuilder(java.lang.String fieldName, java.lang.String value)Constructs a new fuzzy query.FuzzyQueryBuilder(StreamInput in)Read from a stream. -
Method Summary
Modifier and Type Method Description protected booleandoEquals(FuzzyQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()protected QueryBuilderdoRewrite(QueryRewriteContext queryRewriteContext)protected org.apache.lucene.search.QuerydoToQuery(QueryShardContext context)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)java.lang.StringfieldName()Get the field name for this query.static FuzzyQueryBuilderfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)Fuzzinessfuzziness()FuzzyQueryBuilderfuzziness(Fuzziness fuzziness)java.lang.StringgetWriteableName()Returns the name of the writeable objectintmaxExpansions()FuzzyQueryBuildermaxExpansions(int maxExpansions)intprefixLength()FuzzyQueryBuilderprefixLength(int prefixLength)java.lang.Stringrewrite()FuzzyQueryBuilderrewrite(java.lang.String rewrite)booleantranspositions()FuzzyQueryBuildertranspositions(boolean transpositions)java.lang.Objectvalue()Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeToMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
DEFAULT_FUZZINESS
Default maximum edit distance. Defaults to AUTO. -
DEFAULT_PREFIX_LENGTH
public static final int DEFAULT_PREFIX_LENGTHDefault number of initial characters which will not be “fuzzified”. Defaults to 0.- See Also:
- Constant Field Values
-
DEFAULT_MAX_EXPANSIONS
public static final int DEFAULT_MAX_EXPANSIONSDefault maximum number of terms that the fuzzy query will expand to. Defaults to 50.- See Also:
- Constant Field Values
-
DEFAULT_TRANSPOSITIONS
public static final boolean DEFAULT_TRANSPOSITIONSDefault as to whether transpositions should be treated as a primitive edit operation, instead of classic Levenshtein algorithm. Defaults to true.- See Also:
- Constant Field Values
-
-
Constructor Details
-
FuzzyQueryBuilder
public FuzzyQueryBuilder(java.lang.String fieldName, java.lang.String value)Constructs a new fuzzy query.- Parameters:
fieldName- The name of the fieldvalue- The value of the text
-
FuzzyQueryBuilder
public FuzzyQueryBuilder(java.lang.String fieldName, int value)Constructs a new fuzzy query.- Parameters:
fieldName- The name of the fieldvalue- The value of the text
-
FuzzyQueryBuilder
public FuzzyQueryBuilder(java.lang.String fieldName, long value)Constructs a new fuzzy query.- Parameters:
fieldName- The name of the fieldvalue- The value of the text
-
FuzzyQueryBuilder
public FuzzyQueryBuilder(java.lang.String fieldName, float value)Constructs a new fuzzy query.- Parameters:
fieldName- The name of the fieldvalue- The value of the text
-
FuzzyQueryBuilder
public FuzzyQueryBuilder(java.lang.String fieldName, double value)Constructs a new fuzzy query.- Parameters:
fieldName- The name of the fieldvalue- The value of the text
-
FuzzyQueryBuilder
public FuzzyQueryBuilder(java.lang.String fieldName, boolean value)Constructs a new fuzzy query.- Parameters:
fieldName- The name of the fieldvalue- The value of the text
-
FuzzyQueryBuilder
public FuzzyQueryBuilder(java.lang.String fieldName, java.lang.Object value)Constructs a new fuzzy query.- Parameters:
fieldName- The name of the fieldvalue- The value of the term
-
FuzzyQueryBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractQueryBuilder<FuzzyQueryBuilder>- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()Description copied from interface:MultiTermQueryBuilderGet the field name for this query.- Specified by:
fieldNamein interfaceMultiTermQueryBuilder
-
value
public java.lang.Object value() -
fuzziness
-
fuzziness
-
prefixLength
-
prefixLength
public int prefixLength() -
maxExpansions
-
maxExpansions
public int maxExpansions() -
transpositions
-
transpositions
public boolean transpositions() -
rewrite
-
rewrite
public java.lang.String rewrite() -
doXContent
protected void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
doXContentin classAbstractQueryBuilder<FuzzyQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
public static FuzzyQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()Description copied from interface:NamedWriteableReturns the name of the writeable object- Specified by:
getWriteableNamein interfaceNamedWriteable
-
doRewrite
protected QueryBuilder doRewrite(QueryRewriteContext queryRewriteContext) throws java.io.IOException- Overrides:
doRewritein classAbstractQueryBuilder<FuzzyQueryBuilder>- Throws:
java.io.IOException
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException- Specified by:
doToQueryin classAbstractQueryBuilder<FuzzyQueryBuilder>- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCodein classAbstractQueryBuilder<FuzzyQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<FuzzyQueryBuilder>
-