wildcard-query.asciidoc 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.id` 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,console]
  16. ----
  17. GET /_search
  18. {
  19. "query": {
  20. "wildcard": {
  21. "user.id": {
  22. "value": "ki*y",
  23. "boost": 1.0,
  24. "rewrite": "constant_score"
  25. }
  26. }
  27. }
  28. }
  29. ----
  30. [[wildcard-top-level-params]]
  31. ==== Top-level parameters for `wildcard`
  32. `<field>`::
  33. (Required, object) Field you wish to search.
  34. [[wildcard-query-field-params]]
  35. ==== Parameters for `<field>`
  36. `value`::
  37. (Required, string) Wildcard pattern for terms you wish to find in the provided
  38. `<field>`.
  39. +
  40. --
  41. This parameter supports two wildcard operators:
  42. * `?`, which matches any single character
  43. * `*`, which can match zero or more characters, including an empty one
  44. WARNING: Avoid beginning patterns with `*` or `?`. This can increase
  45. the iterations needed to find matching terms and slow search performance.
  46. --
  47. `boost`::
  48. (Optional, float) Floating point number used to decrease or increase the
  49. <<relevance-scores,relevance scores>> of a query. Defaults to `1.0`.
  50. +
  51. You can use the `boost` parameter to adjust relevance scores for searches
  52. containing two or more queries.
  53. +
  54. Boost values are relative to the default value of `1.0`. A boost value between
  55. `0` and `1.0` decreases the relevance score. A value greater than `1.0`
  56. increases the relevance score.
  57. `rewrite`::
  58. (Optional, string) Method used to rewrite the query. For valid values and more information, see the
  59. <<query-dsl-multi-term-rewrite, `rewrite` parameter>>.
  60. [[wildcard-query-notes]]
  61. ==== Notes
  62. ===== Allow expensive queries
  63. Wildcard queries will not be executed if <<query-dsl-allow-expensive-queries, `search.allow_expensive_queries`>>
  64. is set to false.