esql-syntax.asciidoc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. [[esql-syntax]]
  2. == Syntax reference
  3. [discrete]
  4. [[esql-basic-syntax]]
  5. === Basic syntax
  6. An ESQL query is composed of a <<esql-source-commands,source command>> followed
  7. by an optional series of <<esql-processing-commands,processing commands>>,
  8. separated by a pipe character: `|`. For example:
  9. [source,esql]
  10. ----
  11. source-command
  12. | processing-command1
  13. | processing-command2
  14. ----
  15. The result of a query is the table produced by the final processing command.
  16. For readability, this documentation puts each processing command on a new line.
  17. However, you can write an ESQL query as a single line. The following query is
  18. identical to the previous one:
  19. [source,esql]
  20. ----
  21. source-command | processing-command1 | processing-command2
  22. ----
  23. [discrete]
  24. [[esql-comments]]
  25. === Comments
  26. ESQL uses C++ style comments:
  27. * double slash `//` for single line comments
  28. * `/*` and `*/` for block comments
  29. [source,esql]
  30. ----
  31. // Query the employees index
  32. FROM employees
  33. | WHERE height > 2
  34. ----
  35. [source,esql]
  36. ----
  37. FROM /* Query the employees index */ employees
  38. | WHERE height > 2
  39. ----
  40. [source,esql]
  41. ----
  42. FROM employees
  43. /* Query the
  44. * employees
  45. * index */
  46. | WHERE height > 2
  47. ----
  48. [discrete]
  49. [[esql-timespan-literals]]
  50. === ESQL timespan literals
  51. Datetime intervals and timespans can be expressed using timespan literals.
  52. Timespan literals are a combination of a number and a qualifier. These
  53. qualifiers are supported:
  54. * `millisecond`/`milliseconds`
  55. * `second`/`seconds`
  56. * `minute`/`minutes`
  57. * `hour`/`hours`
  58. * `day`/`days`
  59. * `week`/`weeks`
  60. * `month`/`months`
  61. * `year`/`years`
  62. Timespan literals are not whitespace sensitive. These expressions are all valid:
  63. * `1day`
  64. * `1 day`
  65. * `1 day`