1
0

esql-syntax.asciidoc 1.8 KB

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