esql-get-started.asciidoc 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. [[esql-getting-started]]
  2. == Getting started with {esql}
  3. ++++
  4. <titleabbrev>Getting started</titleabbrev>
  5. ++++
  6. A simple example of an {esql} query is shown below:
  7. [source,esql]
  8. ----
  9. FROM employees
  10. | EVAL age = DATE_DIFF(NOW(), birth_date, 'Y')
  11. | STATS AVG(age) BY department
  12. | SORT age DESC
  13. ----
  14. Each {esql} query starts with a <<esql-commands,source command>>. A source command produces
  15. a table, typically with data from {es}.
  16. image::images/esql/source-command.svg[A source command producing a table from {es},align="center"]
  17. A source command can be followed by one or more
  18. <<esql-commands,processing commands>>. Processing commands change an
  19. input table by adding, removing, or changing rows and columns.
  20. Processing commands can perform filtering, projection, aggregation, and more.
  21. image::images/esql/processing-command.svg[A processing command changing an input table,align="center"]
  22. You can chain processing commands, separated by a pipe character: `|`. Each
  23. processing command works on the output table of the previous command.
  24. image::images/esql/chaining-processing-commands.svg[Processing commands can be chained,align="center"]
  25. The result of a query is the table produced by the final processing command.