wildcard-query.asciidoc 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. [[query-dsl-wildcard-query]]
  2. === Wildcard query
  3. ++++
  4. <titleabbrev>Wildcard</titleabbrev>
  5. ++++
  6. Returns documents that contain terms matching a wildcard pattern.
  7. A wildcard operator is a placeholder that matches one or more characters. For
  8. example, the `*` wildcard operator matches zero or more characters. You can
  9. combine wildcard operators with other characters to create a wildcard pattern.
  10. [[wildcard-query-ex-request]]
  11. ==== Example request
  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`.
  15. [source,js]
  16. ----
  17. GET /_search
  18. {
  19. "query": {
  20. "wildcard": {
  21. "user": {
  22. "value": "ki*y",
  23. "boost": 1.0,
  24. "rewrite": "constant_score"
  25. }
  26. }
  27. }
  28. }
  29. ----
  30. // CONSOLE
  31. [[wildcard-top-level-params]]
  32. ==== Top-level parameters for `wildcard`
  33. `<field>`::
  34. (Required, object) Field you wish to search.
  35. [[wildcard-query-field-params]]
  36. ==== Parameters for `<field>`
  37. `value`::
  38. (Required, string) Wildcard pattern for terms you wish to find in the provided
  39. `<field>`.
  40. +
  41. --
  42. This parameter supports two wildcard operators:
  43. * `?`, which matches any single character
  44. * `*`, which can match zero or more characters, including an empty one
  45. WARNING: Avoid beginning patterns with `*` or `?`. This can increase
  46. the iterations needed to find matching terms and slow search performance.
  47. --
  48. `boost`::
  49. (Optional, float) Floating point number used to decrease or increase the
  50. <<relevance-scores,relevance scores>> of a query. Defaults to `1.0`.
  51. +
  52. You can use the `boost` parameter to adjust relevance scores for searches
  53. containing two or more queries.
  54. +
  55. Boost values are relative to the default value of `1.0`. A boost value between
  56. `0` and `1.0` decreases the relevance score. A value greater than `1.0`
  57. increases the relevance score.
  58. `rewrite`::
  59. (Optional, string) Method used to rewrite the query. For valid values and more information, see the
  60. <<query-dsl-multi-term-rewrite, `rewrite` parameter>>.