|
@@ -5,22 +5,36 @@
|
|
|
:esql-specs: {esql-tests}/testFixtures/src/main/resources
|
|
|
|
|
|
[partintro]
|
|
|
---
|
|
|
|
|
|
preview::[]
|
|
|
|
|
|
-The {es} Query Language ({esql}) is a query language that enables the iterative
|
|
|
-exploration of data.
|
|
|
+The {es} Query Language ({esql}) provides a powerful way to filter, transform, and analyze data stored in {es}.
|
|
|
+Users can author {esql} queries to find specific events, perform statistical analysis, and generate visualizations.
|
|
|
+It supports a wide range of commands and functions that enable users to perform various data operations,
|
|
|
+such as filtering, aggregation, time-series analysis, and more.
|
|
|
|
|
|
-An {esql} query consists of a series of commands, separated by pipes. Each query
|
|
|
-starts with a <<esql-source-commands,source command>>. A source command produces
|
|
|
+The {es} Query Language ({esql}) makes use of "pipes" to manipulate and transform data in a step-by-step fashion.
|
|
|
+This approach allows users to compose a series of operations, where the output of one operation becomes the input for the next,
|
|
|
+enabling complex data transformations and analysis.
|
|
|
+
|
|
|
+A simple example of an {esql} query is shown below:
|
|
|
+[source,esql]
|
|
|
+----
|
|
|
+FROM employees
|
|
|
+| EVAL age = DATE_DIFF(NOW(), birth_date, 'Y')
|
|
|
+| STATS AVG(age) BY department
|
|
|
+| SORT age DESC
|
|
|
+----
|
|
|
+
|
|
|
+Each {esql} query starts with a <<esql-commands,source command>>. A source command produces
|
|
|
a table, typically with data from {es}.
|
|
|
|
|
|
image::images/esql/source-command.svg[A source command producing a table from {es},align="center"]
|
|
|
|
|
|
A source command can be followed by one or more
|
|
|
-<<esql-processing-commands,processing commands>>. Processing commands change an
|
|
|
+<<esql-commands,processing commands>>. Processing commands change an
|
|
|
input table by adding, removing, or changing rows and columns.
|
|
|
+Processing commands can perform filtering, projection, aggregation, and more.
|
|
|
|
|
|
image::images/esql/processing-command.svg[A processing command changing an input table,align="center"]
|
|
|
|
|
@@ -32,78 +46,19 @@ image::images/esql/chaining-processing-commands.svg[Processing commands can be c
|
|
|
The result of a query is the table produced by the final processing command.
|
|
|
|
|
|
[discrete]
|
|
|
-[[esql-console]]
|
|
|
-=== Run an {esql} query
|
|
|
+=== The {esql} Compute Engine
|
|
|
|
|
|
-[discrete]
|
|
|
-==== The {esql} API
|
|
|
+{esql} is more than a language. It represents a significant investment in new compute capabilities within {es}.
|
|
|
+To achieve both the functional and performance requirements for {esql}, it was necessary to build an entirely new
|
|
|
+compute architecture. {esql} search, aggregation, and transformation functions are directly executed within Elasticsearch
|
|
|
+itself. Query expressions are not transpiled to Query DSL for execution. This approach allows {esql} to be extremely performant and versatile.
|
|
|
|
|
|
-Use the <<esql-rest,`_query` endpoint>> to run an {esql} query:
|
|
|
-
|
|
|
-// tag::esql-query-api-example[]
|
|
|
-[source,console]
|
|
|
-----
|
|
|
-POST /_query
|
|
|
-{
|
|
|
- "query": """
|
|
|
- FROM library
|
|
|
- | EVAL year = DATE_TRUNC(1 YEARS, release_date)
|
|
|
- | STATS MAX(page_count) BY year
|
|
|
- | SORT year
|
|
|
- | LIMIT 5
|
|
|
- """
|
|
|
-}
|
|
|
-----
|
|
|
-// TEST[setup:library]
|
|
|
-// end::esql-query-api-example[]
|
|
|
-
|
|
|
-The results come back in rows:
|
|
|
-
|
|
|
-[source,console-result]
|
|
|
-----
|
|
|
-{
|
|
|
- "columns": [
|
|
|
- { "name": "MAX(page_count)", "type": "integer"},
|
|
|
- { "name": "year" , "type": "date"}
|
|
|
- ],
|
|
|
- "values": [
|
|
|
- [268, "1932-01-01T00:00:00.000Z"],
|
|
|
- [224, "1951-01-01T00:00:00.000Z"],
|
|
|
- [227, "1953-01-01T00:00:00.000Z"],
|
|
|
- [335, "1959-01-01T00:00:00.000Z"],
|
|
|
- [604, "1965-01-01T00:00:00.000Z"]
|
|
|
- ]
|
|
|
-}
|
|
|
-----
|
|
|
-
|
|
|
-By default, results are returned as JSON. You can return data in other
|
|
|
-<<esql-rest-format,response formats>> by specifying the `format` parameter in
|
|
|
-the URL or by setting the `Accept` or `Content-Type` HTTP header.
|
|
|
-
|
|
|
-By default, an {esql} query returns up to 500 rows. You can change this using
|
|
|
-the <<esql-limit,`LIMIT` command>>. The previous query's `LIMIT` command limits
|
|
|
-results to 5 rows. The maximum number of returned rows is 10,000 rows,
|
|
|
-regardless of the `LIMIT` value.
|
|
|
-
|
|
|
-[discrete]
|
|
|
-==== {kib}
|
|
|
-
|
|
|
-Use {esql} in Discover to explore a data set. From the data view dropdown,
|
|
|
-select *Try {esql}* to get started.
|
|
|
-
|
|
|
-NOTE: {esql} queries in Discover and Lens are subject to the time range selected
|
|
|
-with the time filter.
|
|
|
-
|
|
|
---
|
|
|
+The new {esql} execution engine was designed with performance in mind — it operates on blocks at a time instead of per row, targets vectorization and cache locality, and embraces specialization and multi-threading. It is a separate component from the existing Elasticsearch aggregation framework with different performance characteristics.
|
|
|
|
|
|
include::esql-get-started.asciidoc[]
|
|
|
|
|
|
include::esql-language.asciidoc[]
|
|
|
|
|
|
-include::esql-commands.asciidoc[]
|
|
|
-
|
|
|
-include::esql-functions-operators.asciidoc[]
|
|
|
-
|
|
|
include::esql-rest.asciidoc[]
|
|
|
|
|
|
include::esql-kibana.asciidoc[]
|