index.asciidoc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. [[esql]]
  2. = {esql}
  3. :esql-tests: {xes-repo-dir}/../../plugin/esql/qa
  4. :esql-specs: {esql-tests}/testFixtures/src/main/resources
  5. [partintro]
  6. --
  7. preview::[]
  8. The {es} Query Language ({esql}) is a query language that enables the iterative
  9. exploration of data.
  10. An {esql} query consists of a series of commands, separated by pipes. Each query
  11. starts with a <<esql-source-commands,source command>>. A source command produces
  12. a table, typically with data from {es}.
  13. image::images/esql/source-command.svg[A source command producing a table from {es},align="center"]
  14. A source command can be followed by one or more
  15. <<esql-processing-commands,processing commands>>. Processing commands change an
  16. input table by adding, removing, or changing rows and columns.
  17. image::images/esql/processing-command.svg[A processing command changing an input table,align="center"]
  18. You can chain processing commands, separated by a pipe character: `|`. Each
  19. processing command works on the output table of the previous command.
  20. image::images/esql/chaining-processing-commands.svg[Processing commands can be chained,align="center"]
  21. The result of a query is the table produced by the final processing command.
  22. [discrete]
  23. [[esql-console]]
  24. === Run an {esql} query
  25. [discrete]
  26. ==== The {esql} API
  27. Use the <<esql-rest,`_query` endpoint>> to run an {esql} query:
  28. // tag::esql-query-api-example[]
  29. [source,console]
  30. ----
  31. POST /_query
  32. {
  33. "query": """
  34. FROM library
  35. | EVAL year = DATE_TRUNC(1 YEARS, release_date)
  36. | STATS MAX(page_count) BY year
  37. | SORT year
  38. | LIMIT 5
  39. """
  40. }
  41. ----
  42. // TEST[setup:library]
  43. // end::esql-query-api-example[]
  44. The results come back in rows:
  45. [source,console-result]
  46. ----
  47. {
  48. "columns": [
  49. { "name": "MAX(page_count)", "type": "integer"},
  50. { "name": "year" , "type": "date"}
  51. ],
  52. "values": [
  53. [268, "1932-01-01T00:00:00.000Z"],
  54. [224, "1951-01-01T00:00:00.000Z"],
  55. [227, "1953-01-01T00:00:00.000Z"],
  56. [335, "1959-01-01T00:00:00.000Z"],
  57. [604, "1965-01-01T00:00:00.000Z"]
  58. ]
  59. }
  60. ----
  61. By default, results are returned as JSON. You can return data in other
  62. <<esql-rest-format,response formats>> by specifying the `format` parameter in
  63. the URL or by setting the `Accept` or `Content-Type` HTTP header.
  64. By default, an {esql} query returns up to 500 rows. You can change this using
  65. the <<esql-limit,`LIMIT` command>>. The previous query's `LIMIT` command limits
  66. results to 5 rows. The maximum number of returned rows is 10,000 rows,
  67. regardless of the `LIMIT` value.
  68. [discrete]
  69. ==== {kib}
  70. Use {esql} in Discover to explore a data set. From the data view dropdown,
  71. select *Try {esql}* to get started.
  72. NOTE: {esql} queries in Discover and Lens are subject to the time range selected
  73. with the time filter.
  74. --
  75. include::esql-get-started.asciidoc[]
  76. include::esql-language.asciidoc[]
  77. include::esql-commands.asciidoc[]
  78. include::esql-functions-operators.asciidoc[]
  79. include::esql-rest.asciidoc[]
  80. include::esql-kibana.asciidoc[]
  81. include::task-management.asciidoc[]
  82. include::esql-limitations.asciidoc[]
  83. :esql-tests!:
  84. :esql-specs!: