Class MultiMatchQueryBuilder
- All Implemented Interfaces:
org.opensearch.core.common.io.stream.NamedWriteable
,org.opensearch.core.common.io.stream.Writeable
,org.opensearch.core.xcontent.ToXContent
,org.opensearch.core.xcontent.ToXContentObject
,QueryBuilder
,Rewriteable<QueryBuilder>
MatchQueryBuilder
but supports multiple fields.- Opensearch.internal:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final int
static final Operator
static final int
static final int
static final MultiMatchQueryBuilder.Type
static final MatchQuery.ZeroTermsQuery
static final String
Fields inherited from class org.opensearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
Fields inherited from interface org.opensearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionMultiMatchQueryBuilder
(Object value, String... fields) Constructs a new text query.MultiMatchQueryBuilder
(org.opensearch.core.common.io.stream.StreamInput in) Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionanalyzer()
Explicitly set the analyzer to use.boolean
Whether phrase queries should be automatically generated for multi terms synonyms.autoGenerateSynonymsPhraseQuery
(boolean enable) cutoffFrequency
(float cutoff) Deprecated.Since max_score optimization landed in 7.0, normal MultiMatchQuery will achieve the same result without any configuration.cutoffFrequency
(Float cutoff) Deprecated.Since max_score optimization landed in 7.0, normal MultiMatchQuery will achieve the same result without any configuration.protected boolean
doEquals
(MultiMatchQueryBuilder other) Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
protected org.apache.lucene.search.Query
doToQuery
(QueryShardContext context) protected void
doWriteTo
(org.opensearch.core.common.io.stream.StreamOutput out) void
doXContent
(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) Adds a field to run the multi match against.Adds a field to run the multi match against with a specific boost.fields()
Add several fields to run the query against with a specific boost.static MultiMatchQueryBuilder
fromXContent
(org.opensearch.core.xcontent.XContentParser parser) Deprecated.Sets the fuzziness used when evaluated to a fuzzy query type.fuzzyRewrite
(String fuzzyRewrite) boolean
fuzzyTranspositions
(boolean fuzzyTranspositions) Sets whether transpositions are supported in fuzzy queries.getType()
Returns the type (for testing)boolean
lenient()
lenient
(boolean lenient) Sets whether format based failures will be ignored.int
maxExpansions
(int maxExpansions) When using fuzzy or prefix type query, the number of term expansions to use.minimumShouldMatch
(String minimumShouldMatch) operator()
Sets the operator to use when using a boolean query.int
prefixLength
(int prefixLength) int
slop()
slop
(int slop) Set the phrase slop if evaluated to a phrase query type.tieBreaker
(float tieBreaker) Tie-Breaker for "best-match" disjunction queries (OR-Queries).tieBreaker
(Float tieBreaker) Tie-Breaker for "best-match" disjunction queries (OR-Queries).type()
Sets the type of the text query.Sets the type of the text query.value()
zeroTermsQuery
(MatchQuery.ZeroTermsQuery zeroTermsQuery) Methods inherited from class org.opensearch.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.opensearch.index.query.QueryBuilder
visit
Methods inherited from interface org.opensearch.core.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
DEFAULT_TYPE
-
DEFAULT_OPERATOR
-
DEFAULT_PHRASE_SLOP
public static final int DEFAULT_PHRASE_SLOP- See Also:
-
DEFAULT_PREFIX_LENGTH
public static final int DEFAULT_PREFIX_LENGTH- See Also:
-
DEFAULT_MAX_EXPANSIONS
public static final int DEFAULT_MAX_EXPANSIONS- See Also:
-
DEFAULT_ZERO_TERMS_QUERY
-
DEFAULT_FUZZY_TRANSPOSITIONS
public static final boolean DEFAULT_FUZZY_TRANSPOSITIONS- See Also:
-
-
Constructor Details
-
MultiMatchQueryBuilder
Constructs a new text query. -
MultiMatchQueryBuilder
public MultiMatchQueryBuilder(org.opensearch.core.common.io.stream.StreamInput in) throws IOException Read from a stream.- Throws:
IOException
-
-
Method Details
-
getType
Returns the type (for testing) -
doWriteTo
- Specified by:
doWriteTo
in classAbstractQueryBuilder<MultiMatchQueryBuilder>
- Throws:
IOException
-
value
-
field
Adds a field to run the multi match against. -
field
Adds a field to run the multi match against with a specific boost. -
fields
Add several fields to run the query against with a specific boost. -
fields
-
type
Sets the type of the text query. -
type
Sets the type of the text query. -
type
-
operator
Sets the operator to use when using a boolean query. Defaults toOR
. -
operator
-
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
-
slop
Set the phrase slop if evaluated to a phrase query type. -
slop
public int slop() -
fuzziness
Deprecated. -
fuzziness
Sets the fuzziness used when evaluated to a fuzzy query type. Defaults to "AUTO". -
fuzziness
-
prefixLength
-
prefixLength
public int prefixLength() -
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
-
minimumShouldMatch
-
fuzzyRewrite
-
fuzzyRewrite
-
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.0
is interpreted as a signal to score queries as "most-match" queries where all matching query clauses are considered for scoring.- See Also:
-
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.0
is interpreted as a signal to score queries as "most-match" queries where all matching query clauses are considered for scoring.- See Also:
-
tieBreaker
-
lenient
Sets whether format based failures will be ignored. -
lenient
public boolean lenient() -
cutoffFrequency
Deprecated.Since max_score optimization landed in 7.0, normal MultiMatchQuery will achieve the same result without any configuration.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
Deprecated.Since max_score optimization landed in 7.0, normal MultiMatchQuery will achieve the same result without any configuration.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
-
zeroTermsQuery
-
zeroTermsQuery
-
autoGenerateSynonymsPhraseQuery
-
autoGenerateSynonymsPhraseQuery
public boolean autoGenerateSynonymsPhraseQuery()Whether phrase queries should be automatically generated for multi terms synonyms. Defaults totrue
. -
fuzzyTranspositions
public boolean fuzzyTranspositions() -
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(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException - Specified by:
doXContent
in classAbstractQueryBuilder<MultiMatchQueryBuilder>
- Throws:
IOException
-
fromXContent
public static MultiMatchQueryBuilder fromXContent(org.opensearch.core.xcontent.XContentParser parser) throws IOException - Throws:
IOException
-
getWriteableName
-
doToQuery
- Specified by:
doToQuery
in classAbstractQueryBuilder<MultiMatchQueryBuilder>
- Throws:
IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCode
in classAbstractQueryBuilder<MultiMatchQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilder
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.- Specified by:
doEquals
in classAbstractQueryBuilder<MultiMatchQueryBuilder>
-