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
,ToXContent
,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
ToXContent.DelegatingMapParams, ToXContent.MapParams, 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 static Fuzziness
DEFAULT_FUZZINESS
Default maximum edit distance.static int
DEFAULT_MAX_EXPANSIONS
Default maximum number of terms that the fuzzy query will expand to.static int
DEFAULT_PREFIX_LENGTH
Default number of initial characters which will not be “fuzzified”.static boolean
DEFAULT_TRANSPOSITIONS
Default as to whether transpositions should be treated as a primitive edit operation, instead of classic Levenshtein algorithm.static java.lang.String
NAME
-
Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
-
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
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 boolean
doEquals(FuzzyQueryBuilder other)
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
doHashCode()
protected org.apache.lucene.search.Query
doToQuery(QueryShardContext context)
protected void
doWriteTo(StreamOutput out)
protected void
doXContent(XContentBuilder builder, ToXContent.Params params)
java.lang.String
fieldName()
Get the field name for this query.static FuzzyQueryBuilder
fromXContent(XContentParser parser)
Fuzziness
fuzziness()
FuzzyQueryBuilder
fuzziness(Fuzziness fuzziness)
java.lang.String
getWriteableName()
Returns the name of the writeable objectint
maxExpansions()
FuzzyQueryBuilder
maxExpansions(int maxExpansions)
int
prefixLength()
FuzzyQueryBuilder
prefixLength(int prefixLength)
java.lang.String
rewrite()
FuzzyQueryBuilder
rewrite(java.lang.String rewrite)
boolean
transpositions()
FuzzyQueryBuilder
transpositions(boolean transpositions)
java.lang.Object
value()
-
Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, doRewrite, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toFilter, toQuery, toString, toString, toXContent, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.index.query.QueryBuilder
boost, boost, getName, queryName, queryName, rewrite, toFilter, toQuery
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
DEFAULT_FUZZINESS
public static final Fuzziness DEFAULT_FUZZINESS
Default maximum edit distance. Defaults to AUTO.
-
DEFAULT_PREFIX_LENGTH
public static final int DEFAULT_PREFIX_LENGTH
Default 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_EXPANSIONS
Default 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_TRANSPOSITIONS
Default as to whether transpositions should be treated as a primitive edit operation, instead of classic Levenshtein algorithm. Defaults to false.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
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
public FuzzyQueryBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
doWriteTo
protected void doWriteTo(StreamOutput out) throws java.io.IOException
- Specified by:
doWriteTo
in classAbstractQueryBuilder<FuzzyQueryBuilder>
- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()
Description copied from interface:MultiTermQueryBuilder
Get the field name for this query.- Specified by:
fieldName
in interfaceMultiTermQueryBuilder
-
value
public java.lang.Object value()
-
fuzziness
public FuzzyQueryBuilder fuzziness(Fuzziness fuzziness)
-
fuzziness
public Fuzziness fuzziness()
-
prefixLength
public FuzzyQueryBuilder prefixLength(int prefixLength)
-
prefixLength
public int prefixLength()
-
maxExpansions
public FuzzyQueryBuilder maxExpansions(int maxExpansions)
-
maxExpansions
public int maxExpansions()
-
transpositions
public FuzzyQueryBuilder transpositions(boolean transpositions)
-
transpositions
public boolean transpositions()
-
rewrite
public FuzzyQueryBuilder rewrite(java.lang.String rewrite)
-
rewrite
public java.lang.String rewrite()
-
doXContent
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
doXContent
in classAbstractQueryBuilder<FuzzyQueryBuilder>
- Throws:
java.io.IOException
-
fromXContent
public static FuzzyQueryBuilder fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()
Description copied from interface:NamedWriteable
Returns the name of the writeable object- Specified by:
getWriteableName
in interfaceNamedWriteable
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException
- Specified by:
doToQuery
in classAbstractQueryBuilder<FuzzyQueryBuilder>
- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()
- Specified by:
doHashCode
in classAbstractQueryBuilder<FuzzyQueryBuilder>
-
doEquals
protected boolean doEquals(FuzzyQueryBuilder other)
Description copied from class:AbstractQueryBuilder
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.- Specified by:
doEquals
in classAbstractQueryBuilder<FuzzyQueryBuilder>
-
-