ES|QL functions and operators
ES|QL provides a comprehensive set of functions and operators for working with data. The reference documentation is divided into the following categories:
Aggregate function list
ABSENTReturns true if the input expression yields no non-null values.
AVGReturns the average of a numeric field.
COUNTReturns the total number of input values.
COUNT_DISTINCTReturns the approximate number of distinct values.
EARLIESTReturns the earliest value of a field sorted by timestamp.
FIRSTReturns the earliest occurrence of a field based on a sort field.
LASTReturns the latest occurrence of a field based on a sort field.
LATESTReturns the latest value of a field sorted by timestamp.
MAXReturns the maximum value of a field.
MEDIANReturns the median value of a numeric field.
MEDIAN_ABSOLUTE_DEVIATIONReturns the median absolute deviation, a robust measure of variability.
MINReturns the minimum value of a field.
PERCENTILEReturns the value at which a certain percentage of observed values occur.
PRESENTReturns true if the input expression yields any non-null values.
SAMPLECollects sample values for a field.
SPARKLINEComputes y-axis values of a sparkline graph for an aggregation over time.
ST_CENTROID_AGGCalculates the spatial centroid over a field with geometry type.
ST_EXTENT_AGGCalculates the spatial extent bounding box over a field with geometry type.
STD_DEVReturns the population standard deviation of a numeric field.
SUMReturns the sum of a numeric expression.
TOPCollects the top values for a field, including repeated values.
VALUESReturns unique deduplicated values as a multivalued field.
VARIANCEReturns the population variance of a numeric field.
WEIGHTED_AVGReturns the weighted average of a numeric expression.
Time-series aggregate function list
ABSENT_OVER_TIMECalculates the absence of a field over a time range.
AVG_OVER_TIMECalculates the average over time of a numeric field.
COUNT_OVER_TIMECalculates the count over time value of a field.
COUNT_DISTINCT_OVER_TIMECalculates the count of distinct values over time for a field.
DELTACalculates the absolute change of a gauge field in a time window.
DERIVCalculates the derivative over time of a numeric field using linear regression.
FIRST_OVER_TIMECalculates the earliest value of a field over a time window.
IDELTACalculates the absolute change between the last two data points of a gauge.
INCREASECalculates the absolute increase of a counter field in a time window.
IRATECalculates the per-second rate of increase between the last two data points.
LAST_OVER_TIMECalculates the latest value of a field over a time window.
MAX_OVER_TIMECalculates the maximum value of a field over a time window.
MIN_OVER_TIMECalculates the minimum value of a field over a time window.
PERCENTILE_OVER_TIMECalculates the percentile over time of a field.
PRESENT_OVER_TIMECalculates the presence of a field over a time range.
RATECalculates the per-second average rate of increase of a counter.
STDDEV_OVER_TIMECalculates the population standard deviation over time of a numeric field.
SUM_OVER_TIMECalculates the sum over time value of a field.
VARIANCE_OVER_TIMECalculates the population variance over time of a numeric field.
Grouping function list
BUCKETCreates groups of values (buckets) from a datetime or numeric input.
CATEGORIZEGroups text messages into categories of similarly formatted text values.
TBUCKETCreates timestamp-based buckets aligned to calendar boundaries.
WITHOUT
Conditional function and expression list
CASEReturns the value for the first condition that evaluates to true.
COALESCEReturns the first of its arguments that is not null.
GREATESTReturns the maximum value from multiple columns.
LEASTReturns the minimum value from multiple columns.
CLAMPClamps values to a specified minimum and maximum range.
CLAMP_MINClamps input values to a lower bound, raising any value below min to min.
CLAMP_MAXClamps input values to an upper bound, reducing any value above max to max.
Date and time function list
DATE_DIFFReturns the difference between two timestamps in the specified unit.
DATE_EXTRACTExtracts parts of a date, like year, month, day, hour.
DATE_FORMATReturns a string representation of a date, in the provided format.
DATE_PARSEParses a string into a date using the specified format.
DATE_TRUNCRounds down a date to the closest interval.
DAY_NAMEReturns the name of the weekday for a date.
MONTH_NAMEReturns the month name for a date.
NOWReturns current date and time.
TRANGEFilters data for a given time range using the @timestamp attribute.
IP function list
CIDR_MATCHReturns true if the provided IP is contained in one of the provided CIDR blocks.
IP_PREFIXTruncates an IP to a given prefix length.
Math function list
ABSReturns the absolute value of a number.
ACOSReturns the arccosine of a number.
ACOSHReturns the inverse hyperbolic cosine of a number.
ASINReturns the arcsine of a number.
ASINHReturns the inverse hyperbolic sine of a number.
ATANReturns the arctangent of a number.
ATAN2Returns the two-argument arctangent of y and x coordinates.
ATANHReturns the inverse hyperbolic tangent of a number.
CBRTReturns the cube root of a number.
CEILRounds a number up to the nearest integer.
COPY_SIGNCombines the magnitude of one number with the sign of another.
COSReturns the cosine of an angle.
COSHReturns the hyperbolic cosine of a number.
EReturns the mathematical constant e.
EXPReturns the value of e raised to the power of the given number.
FLOORRounds a number down to the nearest integer.
HYPOTReturns the hypotenuse of two numbers.
LOGReturns the logarithm of a value to a base.
LOG10Returns the base-10 logarithm of a number.
PIReturns the mathematical constant pi.
POWReturns a value raised to the power of an exponent.
ROUNDRounds a number to the specified number of decimal places.
ROUND_TORounds down to one of a list of fixed points.
SCALBReturns the result of multiplying a number by 2 raised to a scale factor.
SIGNUMReturns the sign of the given number.
SINReturns the sine of an angle.
SINHReturns the hyperbolic sine of a number.
SQRTReturns the square root of a number.
TANReturns the tangent of an angle.
TANHReturns the hyperbolic tangent of a number.
TAUReturns the mathematical constant tau.
Search function list
DECAYCalculates a relevance score that decays with distance from a target origin.
KQLPerforms a KQL query and returns true if it matches the row.
MATCHPerforms a match query on the specified field.
MATCH_PHRASEPerforms a match_phrase query on the specified field.
QSTRPerforms a query string query and returns true if it matches the row.
SCOREReturns relevance scores for full text function expressions.
TOP_SNIPPETSExtracts the best snippets for a query string from a text field.
Spatial function list
- Geospatial predicates
ST_DISTANCEComputes the distance between two points.
ST_INTERSECTSReturns true if two geometries intersect.
ST_DISJOINTReturns whether two geometries are disjoint, sharing no points in common.
ST_CONTAINSReturns whether the first geometry contains the second geometry.
ST_WITHINReturns whether the first geometry is within the second geometry.
- Geometry functions
ST_XExtracts the x coordinate from the supplied point.
ST_YExtracts the y coordinate from the supplied point.
ST_NPOINTSCounts the number of points in the supplied geometry.
ST_BUFFERComputes a buffer area around the input geometry at the specified distance.
ST_SIMPLIFYSimplifies the input geometry using the Douglas-Peucker algorithm with a specified tolerance.
ST_SIMPLIFYPRESERVETOPOLOGYSimplifies the input geometry using a topology-preserving Douglas-Peucker algorithm.
ST_GEOMETRYTYPEReturns the geometry type of the supplied geometry as a string.
ST_DIMENSIONReturns the topological dimension of the supplied geometry.
ST_ISEMPTYReturns true if the supplied geometry is empty.
ST_ENVELOPEDetermines the minimum bounding box of the supplied geometry.
- Grid encoding functions
ST_GEOTILECalculates the geotile of the supplied geo_point at the specified precision.
ST_GEOHEXCalculates the geohex (H3 cell-id) of the supplied geo_point at the specified precision.
ST_GEOHASHCalculates the geohash of the supplied geo_point at the specified precision.
String function list
BIT_LENGTHReturns the bit length of a string.
BYTE_LENGTHReturns the byte length of a string.
CHUNKSplits a text field into smaller chunks.
CONCATConcatenates two or more strings.
CONTAINSChecks whether a keyword substring is contained within another string.
ENDS_WITHChecks whether a keyword string ends with another string.
FROM_BASE64Decodes a base64 string.
HASHComputes the hash of the input using a specified algorithm.
JSON_EXTRACTExtracts a value from a JSON string using JSONPath syntax.
LEFTReturns a substring of the specified length from the left side of a string.
LENGTHReturns the character length of a string.
LOCATEReturns the position of a keyword substring within another string.
LTRIMRemoves leading whitespaces from a string.
MD5Computes the MD5 hash of the input.
REPEATReturns a string repeated a specified number of times.
REPLACEReplaces regular expression matches in a string with a replacement string.
REVERSEReturns the input string in reverse order.
RIGHTReturns a substring of the specified length from the right side of a string.
RTRIMRemoves trailing whitespaces from a string.
SHA1Computes the SHA1 hash of the input.
SHA256Computes the SHA256 hash of the input.
SPACEReturns a string made of the specified number of spaces.
SPLITSplits a single valued string into multiple strings.
STARTS_WITHChecks whether a keyword string starts with another string.
SUBSTRINGReturns a substring of a string, specified by a start position and an optional length.
TO_BASE64Encodes a string to a base64 string.
TO_LOWERReturns a new string converted to lower case.
TO_UPPERReturns a new string converted to upper case.
TRIMRemoves leading and trailing whitespaces from a string.
URL_DECODEDecodes a URL-encoded string.
URL_ENCODEURL-encodes a string with spaces encoded as plus signs.
URL_ENCODE_COMPONENTURL-encodes a string with spaces encoded as percent codes.
Type conversion function list
TO_AGGREGATE_METRIC_DOUBLEConverts a numeric value to an aggregate_metric_double.
TO_BOOLEANConverts a value to a boolean.
TO_CARTESIANPOINTConverts a value to a cartesian_point.
TO_CARTESIANSHAPEConverts a value to a cartesian_shape.
TO_COUNTERConverts a numeric value to its counter type equivalent.
TO_DATEPERIODConverts a value to a date_period.
TO_DATETIMEConverts a value to a date.
TO_DATE_NANOSConverts a value to a nanosecond-resolution date.
TO_DEGREESConverts a number in radians to degrees.
TO_DENSE_VECTORConverts numbers or a hexadecimal string to a dense_vector.
TO_DOUBLEConverts a value to a double.
TO_EXPONENTIAL_HISTOGRAMConverts histogram-like values to an exponential histogram.
TO_GAUGEConverts a counter value to its gauge numeric equivalent.
TO_GEOHASHConverts a value to a geohash.
TO_GEOHEXConverts a value to a geohex.
TO_GEOPOINTConverts a value to a geo_point.
TO_GEOSHAPEConverts a value to a geo_shape.
TO_GEOTILEConverts a value to a geotile.
TO_INTEGERConverts a value to an integer.
TO_IPConverts a string to an IP value.
TO_LONGConverts a value to a long.
TO_RADIANSConverts a number in degrees to radians.
TO_STRINGConverts a value to a string.
TO_TDIGESTConverts an untyped histogram to a TDigest.
TO_TIMEDURATIONConverts a value to a time_duration.
TO_UNSIGNED_LONGConverts a value to an unsigned long.
TO_VERSIONConverts a string to a version value.
Dense vector function list
- Dense vector functions
EMBEDDINGGenerates dense vector embeddings from multimodal input using an inference endpoint.
KNNFinds the k nearest vectors to a query vector using a similarity metric.
TEXT_EMBEDDINGGenerates dense vector embeddings from text input using an inference endpoint.
- Vector similarity functions
V_COSINECalculates the cosine similarity between two dense_vectors.
V_DOT_PRODUCTCalculates the dot product between two dense_vectors.
V_HAMMINGCalculates the Hamming distance between two dense vectors.
V_L1_NORMCalculates the L1 norm (Manhattan distance) between two dense_vectors.
V_L2_NORMCalculates the L2 norm (Euclidean distance) between two dense_vectors.