Class MultiMatchQueryBuilder
- java.lang.Object
-
- org.elasticsearch.index.query.AbstractQueryBuilder<MultiMatchQueryBuilder>
-
- org.elasticsearch.index.query.MultiMatchQueryBuilder
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,QueryBuilder,Rewriteable<QueryBuilder>
public class MultiMatchQueryBuilder extends AbstractQueryBuilder<MultiMatchQueryBuilder>
Same asMatchQueryBuilderbut supports multiple fields.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMultiMatchQueryBuilder.Type-
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 booleanDEFAULT_FUZZY_TRANSPOSITIONSstatic intDEFAULT_MAX_EXPANSIONSstatic OperatorDEFAULT_OPERATORstatic intDEFAULT_PHRASE_SLOPstatic intDEFAULT_PREFIX_LENGTHstatic MultiMatchQueryBuilder.TypeDEFAULT_TYPEstatic MatchQuery.ZeroTermsQueryDEFAULT_ZERO_TERMS_QUERYstatic java.lang.StringNAME-
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 MultiMatchQueryBuilder(java.lang.Object value, java.lang.String... fields)Constructs a new text query.MultiMatchQueryBuilder(StreamInput in)Read from a stream.
-
Method Summary
Modifier and Type Method Description java.lang.Stringanalyzer()MultiMatchQueryBuilderanalyzer(java.lang.String analyzer)Explicitly set the analyzer to use.booleanautoGenerateSynonymsPhraseQuery()Whether phrase queries should be automatically generated for multi terms synonyms.MultiMatchQueryBuilderautoGenerateSynonymsPhraseQuery(boolean enable)java.lang.FloatcutoffFrequency()MultiMatchQueryBuildercutoffFrequency(float cutoff)Set a cutoff value in [0..1] (or absolute number >=1) representing the maximum threshold of a terms document frequency to be considered a low frequency term.MultiMatchQueryBuildercutoffFrequency(java.lang.Float cutoff)Set a cutoff value in [0..1] (or absolute number >=1) representing the maximum threshold of a terms document frequency to be considered a low frequency term.protected booleandoEquals(MultiMatchQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()protected org.apache.lucene.search.QuerydoToQuery(QueryShardContext context)protected voiddoWriteTo(StreamOutput out)voiddoXContent(XContentBuilder builder, ToXContent.Params params)MultiMatchQueryBuilderfield(java.lang.String field)Adds a field to run the multi match against.MultiMatchQueryBuilderfield(java.lang.String field, float boost)Adds a field to run the multi match against with a specific boost.java.util.Map<java.lang.String,java.lang.Float>fields()MultiMatchQueryBuilderfields(java.util.Map<java.lang.String,java.lang.Float> fields)Add several fields to run the query against with a specific boost.static MultiMatchQueryBuilderfromXContent(XContentParser parser)Fuzzinessfuzziness()MultiMatchQueryBuilderfuzziness(java.lang.Object fuzziness)Sets the fuzziness used when evaluated to a fuzzy query type.java.lang.StringfuzzyRewrite()MultiMatchQueryBuilderfuzzyRewrite(java.lang.String fuzzyRewrite)booleanfuzzyTranspositions()MultiMatchQueryBuilderfuzzyTranspositions(boolean fuzzyTranspositions)Sets whether transpositions are supported in fuzzy queries.MultiMatchQueryBuilder.TypegetType()Returns the type (for testing)java.lang.StringgetWriteableName()Returns the name of the writeable objectbooleanlenient()MultiMatchQueryBuilderlenient(boolean lenient)Sets whether format based failures will be ignored.intmaxExpansions()MultiMatchQueryBuildermaxExpansions(int maxExpansions)When using fuzzy or prefix type query, the number of term expansions to use.java.lang.StringminimumShouldMatch()MultiMatchQueryBuilderminimumShouldMatch(java.lang.String minimumShouldMatch)Operatoroperator()MultiMatchQueryBuilderoperator(Operator operator)Sets the operator to use when using a boolean query.intprefixLength()MultiMatchQueryBuilderprefixLength(int prefixLength)intslop()MultiMatchQueryBuilderslop(int slop)Set the phrase slop if evaluated to a phrase query type.java.lang.FloattieBreaker()MultiMatchQueryBuildertieBreaker(float tieBreaker)Tie-Breaker for "best-match" disjunction queries (OR-Queries).MultiMatchQueryBuildertieBreaker(java.lang.Float tieBreaker)Tie-Breaker for "best-match" disjunction queries (OR-Queries).MultiMatchQueryBuilder.Typetype()MultiMatchQueryBuildertype(java.lang.Object type)Sets the type of the text query.MultiMatchQueryBuildertype(MultiMatchQueryBuilder.Type type)Sets the type of the text query.java.lang.Objectvalue()MatchQuery.ZeroTermsQueryzeroTermsQuery()MultiMatchQueryBuilderzeroTermsQuery(MatchQuery.ZeroTermsQuery zeroTermsQuery)-
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, toQuery, toString, toXContent, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
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_TYPE
public static final MultiMatchQueryBuilder.Type DEFAULT_TYPE
-
DEFAULT_OPERATOR
public static final Operator DEFAULT_OPERATOR
-
DEFAULT_PHRASE_SLOP
public static final int DEFAULT_PHRASE_SLOP
- See Also:
- Constant Field Values
-
DEFAULT_PREFIX_LENGTH
public static final int DEFAULT_PREFIX_LENGTH
- See Also:
- Constant Field Values
-
DEFAULT_MAX_EXPANSIONS
public static final int DEFAULT_MAX_EXPANSIONS
- See Also:
- Constant Field Values
-
DEFAULT_ZERO_TERMS_QUERY
public static final MatchQuery.ZeroTermsQuery DEFAULT_ZERO_TERMS_QUERY
-
DEFAULT_FUZZY_TRANSPOSITIONS
public static final boolean DEFAULT_FUZZY_TRANSPOSITIONS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MultiMatchQueryBuilder
public MultiMatchQueryBuilder(java.lang.Object value, java.lang.String... fields)Constructs a new text query.
-
MultiMatchQueryBuilder
public MultiMatchQueryBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
getType
public MultiMatchQueryBuilder.Type getType()
Returns the type (for testing)
-
doWriteTo
protected void doWriteTo(StreamOutput out) throws java.io.IOException
- Specified by:
doWriteToin classAbstractQueryBuilder<MultiMatchQueryBuilder>- Throws:
java.io.IOException
-
value
public java.lang.Object value()
-
field
public MultiMatchQueryBuilder field(java.lang.String field)
Adds a field to run the multi match against.
-
field
public MultiMatchQueryBuilder field(java.lang.String field, float boost)
Adds a field to run the multi match against with a specific boost.
-
fields
public MultiMatchQueryBuilder fields(java.util.Map<java.lang.String,java.lang.Float> fields)
Add several fields to run the query against with a specific boost.
-
fields
public java.util.Map<java.lang.String,java.lang.Float> fields()
-
type
public MultiMatchQueryBuilder type(MultiMatchQueryBuilder.Type type)
Sets the type of the text query.
-
type
public MultiMatchQueryBuilder type(java.lang.Object type)
Sets the type of the text query.
-
type
public MultiMatchQueryBuilder.Type type()
-
operator
public MultiMatchQueryBuilder operator(Operator operator)
Sets the operator to use when using a boolean query. Defaults toOR.
-
operator
public Operator operator()
-
analyzer
public MultiMatchQueryBuilder analyzer(java.lang.String analyzer)
Explicitly set the analyzer to use. Defaults to use explicit mapping config for the field, or, if not set, the default search analyzer.
-
analyzer
public java.lang.String analyzer()
-
slop
public MultiMatchQueryBuilder slop(int slop)
Set the phrase slop if evaluated to a phrase query type.
-
slop
public int slop()
-
fuzziness
public MultiMatchQueryBuilder fuzziness(java.lang.Object fuzziness)
Sets the fuzziness used when evaluated to a fuzzy query type. Defaults to "AUTO".
-
fuzziness
public Fuzziness fuzziness()
-
prefixLength
public MultiMatchQueryBuilder prefixLength(int prefixLength)
-
prefixLength
public int prefixLength()
-
maxExpansions
public MultiMatchQueryBuilder maxExpansions(int maxExpansions)
When using fuzzy or prefix type query, the number of term expansions to use. Defaults to unbounded so its recommended to set it to a reasonable value for faster execution.
-
maxExpansions
public int maxExpansions()
-
minimumShouldMatch
public MultiMatchQueryBuilder minimumShouldMatch(java.lang.String minimumShouldMatch)
-
minimumShouldMatch
public java.lang.String minimumShouldMatch()
-
fuzzyRewrite
public MultiMatchQueryBuilder fuzzyRewrite(java.lang.String fuzzyRewrite)
-
fuzzyRewrite
public java.lang.String fuzzyRewrite()
-
tieBreaker
public MultiMatchQueryBuilder tieBreaker(float tieBreaker)
Tie-Breaker for "best-match" disjunction queries (OR-Queries). The tie breaker capability allows documents that match more than one query clause (in this case on more than one field) to be scored better than documents that match only the best of the fields, without confusing this with the better case of two distinct matches in the multiple fields.
A tie-breaker value of
1.0is interpreted as a signal to score queries as "most-match" queries where all matching query clauses are considered for scoring.- See Also:
MultiMatchQueryBuilder.Type
-
tieBreaker
public MultiMatchQueryBuilder tieBreaker(java.lang.Float tieBreaker)
Tie-Breaker for "best-match" disjunction queries (OR-Queries). The tie breaker capability allows documents that match more than one query clause (in this case on more than one field) to be scored better than documents that match only the best of the fields, without confusing this with the better case of two distinct matches in the multiple fields.
A tie-breaker value of
1.0is interpreted as a signal to score queries as "most-match" queries where all matching query clauses are considered for scoring.- See Also:
MultiMatchQueryBuilder.Type
-
tieBreaker
public java.lang.Float tieBreaker()
-
lenient
public MultiMatchQueryBuilder lenient(boolean lenient)
Sets whether format based failures will be ignored.
-
lenient
public boolean lenient()
-
cutoffFrequency
public MultiMatchQueryBuilder cutoffFrequency(float cutoff)
Set a cutoff value in [0..1] (or absolute number >=1) representing the maximum threshold of a terms document frequency to be considered a low frequency term.
-
cutoffFrequency
public MultiMatchQueryBuilder cutoffFrequency(java.lang.Float cutoff)
Set a cutoff value in [0..1] (or absolute number >=1) representing the maximum threshold of a terms document frequency to be considered a low frequency term.
-
cutoffFrequency
public java.lang.Float cutoffFrequency()
-
zeroTermsQuery
public MultiMatchQueryBuilder zeroTermsQuery(MatchQuery.ZeroTermsQuery zeroTermsQuery)
-
zeroTermsQuery
public MatchQuery.ZeroTermsQuery zeroTermsQuery()
-
autoGenerateSynonymsPhraseQuery
public MultiMatchQueryBuilder autoGenerateSynonymsPhraseQuery(boolean enable)
-
autoGenerateSynonymsPhraseQuery
public boolean autoGenerateSynonymsPhraseQuery()
Whether phrase queries should be automatically generated for multi terms synonyms. Defaults totrue.
-
fuzzyTranspositions
public boolean fuzzyTranspositions()
-
fuzzyTranspositions
public MultiMatchQueryBuilder fuzzyTranspositions(boolean fuzzyTranspositions)
Sets whether transpositions are supported in fuzzy queries.The default metric used by fuzzy queries to determine a match is the Damerau-Levenshtein distance formula which supports transpositions. Setting transposition to false will switch to classic Levenshtein distance.
If not set, Damerau-Levenshtein distance metric will be used.
-
doXContent
public void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
doXContentin classAbstractQueryBuilder<MultiMatchQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
public static MultiMatchQueryBuilder fromXContent(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
-
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext context) throws java.io.IOException
- Specified by:
doToQueryin classAbstractQueryBuilder<MultiMatchQueryBuilder>- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()
- Specified by:
doHashCodein classAbstractQueryBuilder<MultiMatchQueryBuilder>
-
doEquals
protected boolean doEquals(MultiMatchQueryBuilder other)
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<MultiMatchQueryBuilder>
-
-