like.asciidoc 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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.
  9. The following wildcard characters are supported:
  10. * `*` matches zero or more characters.
  11. * `?` matches one character.
  12. include::./types/like.asciidoc[]
  13. [source.merge.styled,esql]
  14. ----
  15. include::{esql-specs}/docs.csv-spec[tag=like]
  16. ----
  17. [%header.monospaced.styled,format=dsv,separator=|]
  18. |===
  19. include::{esql-specs}/docs.csv-spec[tag=like-result]
  20. |===
  21. Matching the exact characters `*` and `.` will require escaping.
  22. The escape character is backslash `\`. Since also backslash is a special character in string literals,
  23. it will require further escaping.
  24. [source.merge.styled,esql]
  25. ----
  26. include::{esql-specs}/string.csv-spec[tag=likeEscapingSingleQuotes]
  27. ----
  28. To reduce the overhead of escaping, we suggest using triple quotes strings `"""`
  29. [source.merge.styled,esql]
  30. ----
  31. include::{esql-specs}/string.csv-spec[tag=likeEscapingTripleQuotes]
  32. ----
  33. // end::body[]