mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 15:47:23 -04:00
[DOCS] More ES|QL backtick examples (#103995)
This commit is contained in:
parent
3768fa6148
commit
c6723a3c1d
6 changed files with 264 additions and 106 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
[source,esql]
|
||||
----
|
||||
EVAL column1 = value1[, ..., columnN = valueN]
|
||||
EVAL [column1 =] value1[, ..., [columnN =] valueN]
|
||||
----
|
||||
|
||||
*Parameters*
|
||||
|
@ -28,11 +28,11 @@ values. `EVAL` supports various functions for calculating values. Refer to
|
|||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/docs.csv-spec[tag=eval]
|
||||
include::{esql-specs}/eval.csv-spec[tag=eval]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/docs.csv-spec[tag=eval-result]
|
||||
include::{esql-specs}/eval.csv-spec[tag=eval-result]
|
||||
|===
|
||||
|
||||
If the specified column already exists, the existing column will be dropped, and
|
||||
|
@ -40,9 +40,34 @@ the new column will be appended to the table:
|
|||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/docs.csv-spec[tag=evalReplace]
|
||||
include::{esql-specs}/eval.csv-spec[tag=evalReplace]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/docs.csv-spec[tag=evalReplace-result]
|
||||
include::{esql-specs}/eval.csv-spec[tag=evalReplace-result]
|
||||
|===
|
||||
|
||||
Specifying the output column name is optional. If not specified, the new column
|
||||
name is equal to the expression. The following query adds a column named
|
||||
`height*3.281`:
|
||||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumn]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumn-result]
|
||||
|===
|
||||
|
||||
Because this name contains special characters, <<esql-identifiers,it needs to be
|
||||
quoted>> with backticks (+{backtick}+) when using it in subsequent commands:
|
||||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumnStats]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/eval.csv-spec[tag=evalUnnamedColumnStats-result]
|
||||
|===
|
||||
|
|
|
@ -47,11 +47,11 @@ Calculating a statistic and grouping by the values of another column:
|
|||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/docs.csv-spec[tag=stats]
|
||||
include::{esql-specs}/stats.csv-spec[tag=stats]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/docs.csv-spec[tag=stats-result]
|
||||
include::{esql-specs}/stats.csv-spec[tag=stats-result]
|
||||
|===
|
||||
|
||||
Omitting `BY` returns one row with the aggregations applied over the entire
|
||||
|
@ -59,18 +59,18 @@ dataset:
|
|||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/docs.csv-spec[tag=statsWithoutBy]
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsWithoutBy]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/docs.csv-spec[tag=statsWithoutBy-result]
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsWithoutBy-result]
|
||||
|===
|
||||
|
||||
It's possible to calculate multiple values:
|
||||
|
||||
[source,esql]
|
||||
----
|
||||
include::{esql-specs}/docs.csv-spec[tag=statsCalcMultipleValues]
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsCalcMultipleValues]
|
||||
----
|
||||
|
||||
It's also possible to group by multiple values (only supported for long and
|
||||
|
@ -78,5 +78,30 @@ keyword family fields):
|
|||
|
||||
[source,esql]
|
||||
----
|
||||
include::{esql-specs}/docs.csv-spec[tag=statsGroupByMultipleValues]
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsGroupByMultipleValues]
|
||||
----
|
||||
|
||||
Specifying the output column name is optional. If not specified, the new column
|
||||
name is equal to the expression. The following query returns a column named
|
||||
`AVG(salary)`:
|
||||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsUnnamedColumn]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsUnnamedColumn-result]
|
||||
|===
|
||||
|
||||
Because this name contains special characters, <<esql-identifiers,it needs to be
|
||||
quoted>> with backticks (+{backtick}+) when using it in subsequent commands:
|
||||
|
||||
[source.merge.styled,esql]
|
||||
----
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsUnnamedColumnEval]
|
||||
----
|
||||
[%header.monospaced.styled,format=dsv,separator=|]
|
||||
|===
|
||||
include::{esql-specs}/stats.csv-spec[tag=statsUnnamedColumnEval-result]
|
||||
|===
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue