like.asciidoc 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. [discrete]
  2. [[esql-like-operator]]
  3. === `LIKE`
  4. // tag::body[]
  5. Use `LIKE` to filter data based on string patterns using wildcards. `LIKE`
  6. usually acts on a field placed on the left-hand side of the operator, but it can
  7. also act on a constant (literal) expression. The right-hand side of the operator
  8. represents the pattern or a list of patterns. If a list of patterns is provided,
  9. the expression will return true if any of the patterns match.
  10. The following wildcard characters are supported:
  11. * `*` matches zero or more characters.
  12. * `?` matches one character.
  13. include::./types/like.asciidoc[]
  14. [source.merge.styled,esql]
  15. ----
  16. include::{esql-specs}/docs.csv-spec[tag=like]
  17. ----
  18. [%header.monospaced.styled,format=dsv,separator=|]
  19. |===
  20. include::{esql-specs}/docs.csv-spec[tag=like-result]
  21. |===
  22. Matching the exact characters `*` and `.` will require escaping.
  23. The escape character is backslash `\`. Since also backslash is a special character in string literals,
  24. it will require further escaping.
  25. [source.merge.styled,esql]
  26. ----
  27. include::{esql-specs}/string.csv-spec[tag=likeEscapingSingleQuotes]
  28. ----
  29. [source.merge.styled,esql]
  30. ----
  31. include::{esql-specs}/where-like.csv-spec[tag=likeListDocExample]
  32. ----
  33. To reduce the overhead of escaping, we suggest using triple quotes strings `"""`
  34. [source.merge.styled,esql]
  35. ----
  36. include::{esql-specs}/string.csv-spec[tag=likeEscapingTripleQuotes]
  37. ----
  38. // end::body[]