wildcard-query.asciidoc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. `case_insensitive`::
  61. (Optional, Boolean) allows case insensitive matching of the
  62. pattern with the indexed field values when set to true. Default is false which means
  63. the case sensitivity of matching depends on the underlying field's mapping.
  64. [[wildcard-query-notes]]
  65. ==== Notes
  66. ===== Allow expensive queries
  67. Wildcard queries will not be executed if <<query-dsl-allow-expensive-queries, `search.allow_expensive_queries`>>
  68. is set to false.