wildcard-query.asciidoc 2.0 KB

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