You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns documents that match a provided text, number, date or boolean value. The
10
-
provided text is analyzed before matching.
11
9
12
-
The `match` query is the standard query for performing a full-text search,
13
-
including options for fuzzy matching.
10
+
Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching.
14
11
15
-
`Match` will also work
16
-
against [semantic_text](/reference/elasticsearch/mapping-reference/semantic-text.md)
17
-
fields. As `semantic_text` does not support lexical text search,
18
-
`match` queries against `semantic_text` fields will automatically perform the
19
-
correct semantic search.
20
-
Because of this, options that specifically target lexical search such as
21
-
`fuzziness` or `analyzer` will be ignored.
12
+
The `match` query is the standard query for performing a full-text search, including options for fuzzy matching.
13
+
14
+
`Match` will also work against [semantic_text](/reference/elasticsearch/mapping-reference/semantic-text.md) fields.
15
+
As `semantic_text` does not support lexical text search,`match` queries against `semantic_text` fields will automatically perform the correct semantic search.
16
+
Because of this, options that specifically target lexical search such as `fuzziness` or `analyzer` will be ignored.
22
17
23
18
## Example request [match-query-ex-request]
24
19
@@ -35,127 +30,89 @@ GET /_search
35
30
}
36
31
```
37
32
33
+
38
34
## Top-level parameters for `match`[match-top-level-params]
39
35
40
36
`<field>`
41
37
: (Required, object) Field you wish to search.
42
38
39
+
43
40
## Parameters for `<field>`[match-field-params]
44
41
45
42
`query`
46
-
: (Required) Text, number, boolean value or date you wish to find in the
47
-
provided `<field>`.
43
+
: (Required) Text, number, boolean value or date you wish to find in the provided `<field>`.
48
44
49
-
The `match`
50
-
query [analyzes](docs-content://manage-data/data-store/text-analysis.md) any
51
-
provided text before performing a search. This means the `match` query can
52
-
search [`text`](/reference/elasticsearch/mapping-reference/text.md) fields for
53
-
analyzed tokens rather than an exact term.
45
+
The `match` query [analyzes](docs-content://manage-data/data-store/text-analysis.md) any provided text before performing a search. This means the `match` query can search [`text`](/reference/elasticsearch/mapping-reference/text.md) fields for analyzed tokens rather than an exact term.
54
46
55
47
56
48
`analyzer`
57
-
: (Optional,
58
-
string) [Analyzer](docs-content://manage-data/data-store/text-analysis.md) used
59
-
to convert the text in the `query` value into tokens. Defaults to
60
-
the [index-time analyzer](docs-content://manage-data/data-store/text-analysis/specify-an-analyzer.md#specify-index-time-analyzer)
61
-
mapped for the `<field>`. If no analyzer is mapped, the index’s default analyzer
62
-
is used.
49
+
: (Optional, string) [Analyzer](docs-content://manage-data/data-store/text-analysis.md) used to convert the text in the `query` value into tokens. Defaults to the [index-time analyzer](docs-content://manage-data/data-store/text-analysis/specify-an-analyzer.md#specify-index-time-analyzer) mapped for the `<field>`. If no analyzer is mapped, the index’s default analyzer is used.
queries are automatically created for multi-term synonyms. Defaults to `true`.
52
+
: (Optional, Boolean) If `true`, [match phrase](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md) queries are automatically created for multi-term synonyms. Defaults to `true`.
68
53
69
-
See [Use synonyms with match query](#query-dsl-match-query-synonyms) for an
70
-
example.
54
+
See [Use synonyms with match query](#query-dsl-match-query-synonyms) for an example.
71
55
72
56
73
57
`boost`
74
-
: (Optional, float) Floating point number used to decrease or increase
75
-
the [relevance scores](/reference/query-languages/query-dsl/query-filter-context.md#relevance-scores)
76
-
of the query. Defaults to `1.0`.
58
+
: (Optional, float) Floating point number used to decrease or increase the [relevance scores](/reference/query-languages/query-dsl/query-filter-context.md#relevance-scores) of the query. Defaults to `1.0`.
77
59
78
-
Boost values are relative to the default value of `1.0`. A boost value between
79
-
`0` and `1.0` decreases the relevance score. A value greater than `1.0`
80
-
increases the relevance score.
60
+
Boost values are relative to the default value of `1.0`. A boost value between `0` and `1.0` decreases the relevance score. A value greater than `1.0` increases the relevance score.
81
61
82
62
83
63
`fuzziness`
84
-
: (Optional, string) Maximum edit distance allowed for matching.
85
-
See [Fuzziness](/reference/elasticsearch/rest-apis/common-options.md#fuzziness)
86
-
for valid values and more information.
87
-
See [Fuzziness in the match query](#query-dsl-match-query-fuzziness) for an
88
-
example.
64
+
: (Optional, string) Maximum edit distance allowed for matching. See [Fuzziness](/reference/elasticsearch/rest-apis/common-options.md#fuzziness) for valid values and more information. See [Fuzziness in the match query](#query-dsl-match-query-fuzziness) for an example.
89
65
90
66
`max_expansions`
91
-
: (Optional, integer) Maximum number of terms to which the query will expand.
92
-
Defaults to `50`.
67
+
: (Optional, integer) Maximum number of terms to which the query will expand. Defaults to `50`.
93
68
94
69
`prefix_length`
95
-
: (Optional, integer) Number of beginning characters left unchanged for fuzzy
96
-
matching. Defaults to `0`.
70
+
: (Optional, integer) Number of beginning characters left unchanged for fuzzy matching. Defaults to `0`.
97
71
98
72
`fuzzy_transpositions`
99
-
: (Optional, Boolean) If `true`, edits for fuzzy matching include
100
-
transpositions of two adjacent characters (ab → ba). Defaults to `true`.
73
+
: (Optional, Boolean) If `true`, edits for fuzzy matching include transpositions of two adjacent characters (ab → ba). Defaults to `true`.
101
74
102
75
`fuzzy_rewrite`
103
-
: (Optional, string) Method used to rewrite the query. See the [
: (Optional, string) Method used to rewrite the query. See the [`rewrite` parameter](/reference/query-languages/query-dsl/query-dsl-multi-term-rewrite.md) for valid values and more information.
106
77
107
-
If the `fuzziness` parameter is not `0`, the `match` query uses a
108
-
`fuzzy_rewrite` method of `top_terms_blended_freqs_${max_expansions}` by
109
-
default.
78
+
If the `fuzziness` parameter is not `0`, the `match` query uses a `fuzzy_rewrite` method of `top_terms_blended_freqs_${max_expansions}` by default.
110
79
111
80
112
81
`lenient`
113
-
: (Optional, Boolean) If `true`, format-based errors, such as providing a text
114
-
`query` value for
115
-
a [numeric](/reference/elasticsearch/mapping-reference/number.md) field, are
116
-
ignored. Defaults to `false`.
82
+
: (Optional, Boolean) If `true`, format-based errors, such as providing a text `query` value for a [numeric](/reference/elasticsearch/mapping-reference/number.md) field, are ignored. Defaults to `false`.
117
83
118
84
`operator`
119
-
: (Optional, string) Boolean logic used to interpret text in the `query`
120
-
value. Valid values are:
85
+
: (Optional, string) Boolean logic used to interpret text in the `query` value. Valid values are:
121
86
122
87
`OR` (Default)
123
-
: For example, a `query` value of `capital of Hungary` is interpreted as
124
-
`capital OR of OR Hungary`.
88
+
: For example, a `query` value of `capital of Hungary` is interpreted as `capital OR of OR Hungary`.
125
89
126
90
`AND`
127
-
: For example, a `query` value of `capital of Hungary` is interpreted as
128
-
`capital AND of AND Hungary`.
91
+
: For example, a `query` value of `capital of Hungary` is interpreted as `capital AND of AND Hungary`.
129
92
130
93
131
94
`minimum_should_match`
132
-
: (Optional, string) Minimum number of clauses that must match for a document
: (Optional, string) Minimum number of clauses that must match for a document to be returned. See the [`minimum_should_match` parameter](/reference/query-languages/query-dsl/query-dsl-minimum-should-match.md) for valid values and more information.
136
96
137
97
138
98
`zero_terms_query`
139
-
: (Optional, string) Indicates whether no documents are returned if the
140
-
`analyzer` removes all tokens, such as when using a `stop` filter. Valid values
141
-
are:
99
+
: (Optional, string) Indicates whether no documents are returned if the `analyzer` removes all tokens, such as when using a `stop` filter. Valid values are:
142
100
143
101
`none` (Default)
144
102
: No documents are returned if the `analyzer` removes all tokens.
The `match` query is of type `boolean`. It means that the text provided is analyzed and the analysis process constructs a boolean query from the provided text. The `operator` parameter can be set to `or` or `and` to control the boolean clauses (defaults to `or`). The minimum number of optional `should` clauses to match can be set using the [`minimum_should_match`](/reference/query-languages/query-dsl/query-dsl-minimum-should-match.md) parameter.
180
132
181
133
Here is an example with the `operator` parameter:
182
134
@@ -194,37 +146,24 @@ GET /_search
194
146
}
195
147
```
196
148
197
-
The `analyzer` can be set to control which analyzer will perform the analysis
198
-
process on the text. It defaults to the field explicit mapping definition, or
199
-
the default search analyzer.
149
+
The `analyzer` can be set to control which analyzer will perform the analysis process on the text. It defaults to the field explicit mapping definition, or the default search analyzer.
150
+
151
+
The `lenient` parameter can be set to `true` to ignore exceptions caused by data-type mismatches, such as trying to query a numeric field with a text query string. Defaults to `false`.
200
152
201
-
The `lenient` parameter can be set to `true` to ignore exceptions caused by
202
-
data-type mismatches, such as trying to query a numeric field with a text query
203
-
string. Defaults to `false`.
204
153
205
154
### Fuzziness in the match query [query-dsl-match-query-fuzziness]
206
155
207
-
`fuzziness` allows *fuzzy matching* based on the type of field being queried.
208
-
See [Fuzziness](/reference/elasticsearch/rest-apis/common-options.md#fuzziness)
209
-
for allowed settings.
156
+
`fuzziness` allows *fuzzy matching* based on the type of field being queried. See [Fuzziness](/reference/elasticsearch/rest-apis/common-options.md#fuzziness) for allowed settings.
210
157
211
-
The `prefix_length` and `max_expansions` can be set in this case to control the
212
-
fuzzy process. If the fuzzy option is set the query will use
213
-
`top_terms_blended_freqs_${max_expansions}` as
214
-
its [rewrite method](/reference/query-languages/query-dsl/query-dsl-multi-term-rewrite.md)
215
-
the `fuzzy_rewrite` parameter allows to control how the query will get
216
-
rewritten.
158
+
The `prefix_length` and `max_expansions` can be set in this case to control the fuzzy process. If the fuzzy option is set the query will use `top_terms_blended_freqs_${max_expansions}` as its [rewrite method](/reference/query-languages/query-dsl/query-dsl-multi-term-rewrite.md) the `fuzzy_rewrite` parameter allows to control how the query will get rewritten.
217
159
218
-
Fuzzy transpositions (`ab` → `ba`) are allowed by default but can be disabled by
219
-
setting `fuzzy_transpositions` to `false`.
160
+
Fuzzy transpositions (`ab` → `ba`) are allowed by default but can be disabled by setting `fuzzy_transpositions` to `false`.
220
161
221
162
::::{note}
222
-
Fuzzy matching is not applied to terms with synonyms or in cases where the
223
-
analysis process produces multiple tokens at the same position. Under the hood
224
-
these terms are expanded to a special synonym query that blends term
225
-
frequencies, which does not support fuzzy expansion.
163
+
Fuzzy matching is not applied to terms with synonyms or in cases where the analysis process produces multiple tokens at the same position. Under the hood these terms are expanded to a special synonym query that blends term frequencies, which does not support fuzzy expansion.
226
164
::::
227
165
166
+
228
167
```console
229
168
GET /_search
230
169
{
@@ -239,12 +178,10 @@ GET /_search
239
178
}
240
179
```
241
180
181
+
242
182
### Zero terms query [query-dsl-match-query-zero]
243
183
244
-
If the analyzer used removes all tokens in a query like a `stop` filter does,
245
-
the default behavior is to match no documents at all. In order to change that
246
-
the `zero_terms_query` option can be used, which accepts `none` (default) and
247
-
`all` which corresponds to a `match_all` query.
184
+
If the analyzer used removes all tokens in a query like a `stop` filter does, the default behavior is to match no documents at all. In order to change that the `zero_terms_query` option can be used, which accepts `none` (default) and `all` which corresponds to a `match_all` query.
248
185
249
186
```console
250
187
GET /_search
@@ -261,13 +198,10 @@ GET /_search
261
198
}
262
199
```
263
200
201
+
264
202
### Synonyms [query-dsl-match-query-synonyms]
265
203
266
-
The `match` query supports multi-terms synonym expansion with
267
-
the [synonym_graph](/reference/text-analysis/analysis-synonym-graph-tokenfilter.md)
268
-
token filter. When this filter is used, the parser creates a phrase query for
269
-
each multi-terms synonyms. For example, the following synonym: `"ny, new york"`
270
-
would produce:
204
+
The `match` query supports multi-terms synonym expansion with the [synonym_graph](/reference/text-analysis/analysis-synonym-graph-tokenfilter.md) token filter. When this filter is used, the parser creates a phrase query for each multi-terms synonyms. For example, the following synonym: `"ny, new york"` would produce:
271
205
272
206
`(ny OR ("new york"))`
273
207
@@ -291,8 +225,7 @@ The example above creates a boolean query:
291
225
292
226
`(ny OR (new AND york)) city`
293
227
294
-
that matches documents with the term `ny` or the conjunction `new AND york`. By
295
-
default the parameter `auto_generate_synonyms_phrase_query` is set to `true`.
228
+
that matches documents with the term `ny` or the conjunction `new AND york`. By default the parameter `auto_generate_synonyms_phrase_query` is set to `true`.
0 commit comments