Loading

ES|QL PRESENT function

Embedded
field

Expression that outputs values to be checked for presence.

Returns true if the input expression yields any non-null values within the current aggregation context. Otherwise it returns false.

field result
aggregate_metric_double boolean
boolean boolean
cartesian_point boolean
cartesian_shape boolean
date boolean
date_nanos boolean
dense_vector boolean
double boolean
exponential_histogram boolean
geo_point boolean
geo_shape boolean
geohash boolean
geohex boolean
geotile boolean
histogram boolean
integer boolean
ip boolean
keyword boolean
long boolean
tdigest boolean
text boolean
unsigned_long boolean
version boolean
FROM employees
| STATS is_present = PRESENT(languages)
		
is_present:boolean
true

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

FROM employees
| STATS is_present = PRESENT(salary) BY languages
		
is_present:boolean languages:integer
true 1
true 2
true 3
true 4
true 5
true null

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

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