Skip to content

Commit 589d7bc

Browse files
committed
Fix whitespace
1 parent 92e9e98 commit 589d7bc

File tree

1 file changed

+46
-113
lines changed

1 file changed

+46
-113
lines changed

docs/reference/query-languages/query-dsl/query-dsl-match-query.md

Lines changed: 46 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ mapped_pages:
66

77
# Match query [query-dsl-match-query]
88

9-
Returns documents that match a provided text, number, date or boolean value. The
10-
provided text is analyzed before matching.
119

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.
1411

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.
2217

2318
## Example request [match-query-ex-request]
2419

@@ -35,127 +30,89 @@ GET /_search
3530
}
3631
```
3732

33+
3834
## Top-level parameters for `match` [match-top-level-params]
3935

4036
`<field>`
4137
: (Required, object) Field you wish to search.
4238

39+
4340
## Parameters for `<field>` [match-field-params]
4441

4542
`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>`.
4844

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.
5446

5547

5648
`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.
6350

6451
`auto_generate_synonyms_phrase_query`
65-
: (Optional, Boolean) If
66-
`true`, [match phrase](/reference/query-languages/query-dsl/query-dsl-match-query-phrase.md)
67-
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`.
6853

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.
7155

7256

7357
`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`.
7759

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.
8161

8262

8363
`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.
8965

9066
`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`.
9368

9469
`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`.
9771

9872
`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`.
10174

10275
`fuzzy_rewrite`
103-
: (Optional, string) Method used to rewrite the query. See the [
104-
`rewrite` parameter](/reference/query-languages/query-dsl/query-dsl-multi-term-rewrite.md)
105-
for valid values and more information.
76+
: (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.
10677

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.
11079

11180

11281
`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`.
11783

11884
`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:
12186

12287
`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`.
12589

12690
`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`.
12992

13093

13194
`minimum_should_match`
132-
: (Optional, string) Minimum number of clauses that must match for a document
133-
to be returned. See the [
134-
`minimum_should_match` parameter](/reference/query-languages/query-dsl/query-dsl-minimum-should-match.md)
135-
for valid values and more information.
95+
: (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.
13696

13797

13898
`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:
142100

143101
`none` (Default)
144102
: No documents are returned if the `analyzer` removes all tokens.
145103

146104
`all`
147-
: Returns all documents, similar to a [
148-
`match_all`](/reference/query-languages/query-dsl/query-dsl-match-all-query.md)
149-
query.
105+
: Returns all documents, similar to a [`match_all`](/reference/query-languages/query-dsl/query-dsl-match-all-query.md) query.
150106

151107
See [Zero terms query](#query-dsl-match-query-zero) for an example.
152108

109+
110+
153111
## Notes [match-query-notes]
154112

155113
### Short request example [query-dsl-match-query-short-ex]
156114

157-
You can simplify the match query syntax by combining the `<field>` and `query`
158-
parameters. For example:
115+
You can simplify the match query syntax by combining the `<field>` and `query` parameters. For example:
159116

160117
```console
161118
GET /_search
@@ -168,15 +125,10 @@ GET /_search
168125
}
169126
```
170127

128+
171129
### How the match query works [query-dsl-match-query-boolean]
172130

173-
The `match` query is of type `boolean`. It means that the text provided is
174-
analyzed and the analysis process constructs a boolean query from the provided
175-
text. The `operator` parameter can be set to `or` or `and` to control the
176-
boolean clauses (defaults to `or`). The minimum number of optional `should`
177-
clauses to match can be set using the [
178-
`minimum_should_match`](/reference/query-languages/query-dsl/query-dsl-minimum-should-match.md)
179-
parameter.
131+
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.
180132

181133
Here is an example with the `operator` parameter:
182134

@@ -194,37 +146,24 @@ GET /_search
194146
}
195147
```
196148

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`.
200152

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`.
204153

205154
### Fuzziness in the match query [query-dsl-match-query-fuzziness]
206155

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.
210157

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.
217159

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`.
220161

221162
::::{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.
226164
::::
227165

166+
228167
```console
229168
GET /_search
230169
{
@@ -239,12 +178,10 @@ GET /_search
239178
}
240179
```
241180

181+
242182
### Zero terms query [query-dsl-match-query-zero]
243183

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.
248185

249186
```console
250187
GET /_search
@@ -261,13 +198,10 @@ GET /_search
261198
}
262199
```
263200

201+
264202
### Synonyms [query-dsl-match-query-synonyms]
265203

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:
271205

272206
`(ny OR ("new york"))`
273207

@@ -291,8 +225,7 @@ The example above creates a boolean query:
291225

292226
`(ny OR (new AND york)) city`
293227

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`.
296229

297230

298231

0 commit comments

Comments
 (0)