|
1 | 1 | [[query-dsl-wildcard-query]]
|
2 | 2 | === Wildcard Query
|
| 3 | +Returns documents that contain terms matching a wildcard pattern. |
3 | 4 |
|
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. |
11 | 8 |
|
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 |
22 | 11 |
|
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`. |
24 | 15 |
|
25 | 16 | [source,js]
|
26 |
| --------------------------------------------------- |
| 17 | +---- |
27 | 18 | GET /_search
|
28 | 19 | {
|
29 | 20 | "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 | + } |
31 | 28 | }
|
32 | 29 | }
|
33 |
| --------------------------------------------------- |
| 30 | +---- |
34 | 31 | // CONSOLE
|
35 | 32 |
|
36 |
| -Or : |
| 33 | +[[wildcard-top-level-params]] |
| 34 | +==== Top-level parameters for `wildcard` |
| 35 | +`<field>`:: |
| 36 | +Field you wish to search. |
37 | 37 |
|
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. |
48 | 64 |
|
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