Skip to content

Commit 05bc599

Browse files
committed
[DOCS] Rewrite 'wildcard' query (#42670)
1 parent 75b3433 commit 05bc599

File tree

1 file changed

+51
-35
lines changed

1 file changed

+51
-35
lines changed
Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,67 @@
11
[[query-dsl-wildcard-query]]
22
=== Wildcard Query
3+
Returns documents that contain terms matching a wildcard pattern.
34

4-
Matches documents that have fields matching a wildcard expression (*not
5-
analyzed*). Supported wildcards are `*`, which matches any character
6-
sequence (including the empty one), and `?`, which matches any single
7-
character. Note that this query can be slow, as it needs to iterate over many
8-
terms. In order to prevent extremely slow wildcard queries, a wildcard
9-
term should not start with one of the wildcards `*` or `?`. The wildcard
10-
query maps to Lucene `WildcardQuery`.
5+
A wildcard operator is a placeholder that matches one or more characters. For
6+
example, the `*` wildcard operator matches zero or more characters. You can
7+
combine wildcard operators with other characters to create a wildcard pattern.
118

12-
[source,js]
13-
--------------------------------------------------
14-
GET /_search
15-
{
16-
"query": {
17-
"wildcard" : { "user" : "ki*y" }
18-
}
19-
}
20-
--------------------------------------------------
21-
// CONSOLE
9+
[[wildcard-query-ex-request]]
10+
==== Example request
2211

23-
A boost can also be associated with the query:
12+
The following search returns documents where the `user` field contains a term
13+
that begins with `ki` and ends with `y`. These matching terms can include `kiy`,
14+
`kity`, or `kimchy`.
2415

2516
[source,js]
26-
--------------------------------------------------
17+
----
2718
GET /_search
2819
{
2920
"query": {
30-
"wildcard" : { "user" : { "value" : "ki*y", "boost" : 2.0 } }
21+
"wildcard": {
22+
"user": {
23+
"value": "ki*y",
24+
"boost": 1.0,
25+
"rewrite": "constant_score"
26+
}
27+
}
3128
}
3229
}
33-
--------------------------------------------------
30+
----
3431
// CONSOLE
3532

36-
Or :
33+
[[wildcard-top-level-params]]
34+
==== Top-level parameters for `wildcard`
35+
`<field>`::
36+
Field you wish to search.
3737

38-
[source,js]
39-
--------------------------------------------------
40-
GET /_search
41-
{
42-
"query": {
43-
"wildcard" : { "user" : { "wildcard" : "ki*y", "boost" : 2.0 } }
44-
}
45-
}
46-
--------------------------------------------------
47-
// CONSOLE
38+
[[wildcard-query-field-params]]
39+
==== Parameters for `<field>`
40+
`value`::
41+
Wildcard pattern for terms you wish to find in the provided `<field>`.
42+
+
43+
--
44+
This parameter supports two wildcard operators:
45+
46+
* `?`, which matches any single character
47+
* `*`, which can match zero or more characters, including an empty one
48+
49+
WARNING: Avoid beginning patterns with `*` or `?`. This can increase
50+
the iterations needed to find matching terms and slow search performance.
51+
--
52+
53+
`boost`::
54+
Floating point number used to decrease or increase the
55+
<<query-filter-context, relevance scores>> of a query. Default is `1.0`.
56+
Optional.
57+
+
58+
You can use the `boost` parameter to adjust relevance scores for searches
59+
containing two or more queries.
60+
+
61+
Boost values are relative to the default value of `1.0`. A boost value between
62+
`0` and `1.0` decreases the relevance score. A value greater than `1.0`
63+
increases the relevance score.
4864

49-
This multi term query allows to control how it gets rewritten using the
50-
<<query-dsl-multi-term-rewrite,rewrite>>
51-
parameter.
65+
`rewrite` (Expert)::
66+
Method used to rewrite the query. For valid values and more information, see the
67+
<<query-dsl-multi-term-rewrite, `rewrite` parameter>>. Optional.

0 commit comments

Comments
 (0)