-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Description
We already support the following decay functions in painless for the script_score query:
double decayNumericLinear(double origin, double scale, double offset, double decay, double docValue)
double decayNumericExp(double origin, double scale, double offset, double decay, double docValue)
double decayNumericGauss(double origin, double scale, double offset, double decay, double docValue)
double decayGeoLinear(String originStr, String scaleStr, String offsetStr, double decay, GeoPoint docValue)
double decayGeoExp(String originStr, String scaleStr, String offsetStr, double decay, GeoPoint docValue)
double decayGeoGauss(String originStr, String scaleStr, String offsetStr, double decay, GeoPoint docValue)
double decayDateLinear(String originStr, String scaleStr, String offsetStr, double decay, JodaCompatibleZonedDateTime docValueDate)
double decayDateExp(String originStr, String scaleStr, String offsetStr, double decay, JodaCompatibleZonedDateTime docValueDate)
double decayDateGauss(String originStr, String scaleStr, String offsetStr, double decay, JodaCompatibleZonedDateTime docValueDate)
Decay functions are used to penalize scores based on recency (for date types) or distance (numeric and geo types) and this is a useful feature we want to add to ES|QL.
We do not want to add 9 different decay functions.
We will have 3 decay functions:
decay_linear(origin, scale, offset, decay, value)
decay_exp(origin, scale, offset, decay, value)
decay_gauss(origin, scale, offset, decay, value)
For parameters:
Origin: numeric, spatial, date types
Scale: numeric, spatial, date types
Offset: numeric, spatial, date types
Decay: numeric
Value: numeric, spatial, date types
The return type should be double.
In terms of priority - it would make sense to add support for linear and exponential first, with gauss decay being used less in practice.
As a note we could potentially have a single function:
decay(type, origin, scale, offset, decay, value)
where type can be "linear"
, "exp"
or "gauss"
.
Activity
elasticsearchmachine commentedon Feb 3, 2025
Pinging @elastic/es-search-relevance (Team:Search Relevance)
elasticsearchmachine commentedon Mar 19, 2025
Pinging @elastic/kibana-esql (ES|QL-ui)
[-]ESQL: Add decay function[/-][+]ESQL: Add decay functions[/+]