Back to Elasticsearch

Present

docs/reference/query-languages/esql/_snippets/functions/examples/present.md

9.4.0747 B
Original Source

% This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.

Examples

esql
FROM employees
| STATS is_present = PRESENT(languages)
is_present:boolean
true

To check for the presence inside a group use PRESENT() and BY clauses

esql
FROM employees
| STATS is_present = PRESENT(salary) BY languages
is_present:booleanlanguages:integer
true1
true2
true3
true4
true5
truenull

To check for the presence and return 1 when it's true and 0 when it's false

esql
FROM employees
| WHERE emp_no == 10020
| STATS is_present = TO_INTEGER(PRESENT(languages))
is_present:integer
0