2013-08-28 19:24:34 -04:00
|
|
|
[[query-dsl-wildcard-query]]
|
2019-07-18 10:18:11 -04:00
|
|
|
=== Wildcard query
|
|
|
|
++++
|
|
|
|
<titleabbrev>Wildcard</titleabbrev>
|
|
|
|
++++
|
|
|
|
|
2019-05-30 08:30:30 -04:00
|
|
|
Returns documents that contain terms matching a wildcard pattern.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-05-30 08:30:30 -04:00
|
|
|
A wildcard operator is a placeholder that matches one or more characters. For
|
|
|
|
example, the `*` wildcard operator matches zero or more characters. You can
|
|
|
|
combine wildcard operators with other characters to create a wildcard pattern.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-05-30 08:30:30 -04:00
|
|
|
[[wildcard-query-ex-request]]
|
|
|
|
==== Example request
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-08-03 13:31:19 -04:00
|
|
|
The following search returns documents where the `user.id` field contains a term
|
2019-05-30 08:30:30 -04:00
|
|
|
that begins with `ki` and ends with `y`. These matching terms can include `kiy`,
|
|
|
|
`kity`, or `kimchy`.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2019-05-30 08:30:30 -04:00
|
|
|
----
|
2016-05-24 05:58:43 -04:00
|
|
|
GET /_search
|
2013-08-28 19:24:34 -04:00
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"query": {
|
|
|
|
"wildcard": {
|
2020-08-03 13:31:19 -04:00
|
|
|
"user.id": {
|
2020-07-21 15:49:58 -04:00
|
|
|
"value": "ki*y",
|
|
|
|
"boost": 1.0,
|
|
|
|
"rewrite": "constant_score"
|
|
|
|
}
|
2016-05-24 05:58:43 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2013-08-28 19:24:34 -04:00
|
|
|
}
|
2019-05-30 08:30:30 -04:00
|
|
|
----
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-05-30 08:30:30 -04:00
|
|
|
[[wildcard-top-level-params]]
|
|
|
|
==== Top-level parameters for `wildcard`
|
|
|
|
`<field>`::
|
2019-07-31 14:18:22 -04:00
|
|
|
(Required, object) Field you wish to search.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-05-30 08:30:30 -04:00
|
|
|
[[wildcard-query-field-params]]
|
|
|
|
==== Parameters for `<field>`
|
|
|
|
`value`::
|
2019-07-31 14:18:22 -04:00
|
|
|
(Required, string) Wildcard pattern for terms you wish to find in the provided
|
|
|
|
`<field>`.
|
2019-05-30 08:30:30 -04:00
|
|
|
+
|
|
|
|
--
|
|
|
|
This parameter supports two wildcard operators:
|
|
|
|
|
|
|
|
* `?`, which matches any single character
|
|
|
|
* `*`, which can match zero or more characters, including an empty one
|
|
|
|
|
|
|
|
WARNING: Avoid beginning patterns with `*` or `?`. This can increase
|
|
|
|
the iterations needed to find matching terms and slow search performance.
|
|
|
|
--
|
|
|
|
|
|
|
|
`boost`::
|
2019-07-31 14:18:22 -04:00
|
|
|
(Optional, float) Floating point number used to decrease or increase the
|
2019-08-02 14:15:12 -04:00
|
|
|
<<relevance-scores,relevance scores>> of a query. Defaults to `1.0`.
|
2019-05-30 08:30:30 -04:00
|
|
|
+
|
|
|
|
You can use the `boost` parameter to adjust relevance scores for searches
|
|
|
|
containing two or more queries.
|
|
|
|
+
|
|
|
|
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.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-07-31 14:18:22 -04:00
|
|
|
`rewrite`::
|
|
|
|
(Optional, string) Method used to rewrite the query. For valid values and more information, see the
|
2020-02-12 16:56:14 -05:00
|
|
|
<<query-dsl-multi-term-rewrite, `rewrite` parameter>>.
|
|
|
|
|
2020-08-12 14:01:10 -04:00
|
|
|
[[wildcard-query-notes]]
|
2020-02-12 16:56:14 -05:00
|
|
|
==== Notes
|
|
|
|
===== Allow expensive queries
|
|
|
|
Wildcard queries will not be executed if <<query-dsl-allow-expensive-queries, `search.allow_expensive_queries`>>
|
|
|
|
is set to false.
|