Skip to content

ESQL: Add decay function #121526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #98545
ioanatia opened this issue Feb 3, 2025 · 2 comments
Open
Tracked by #98545

ESQL: Add decay function #121526

ioanatia opened this issue Feb 3, 2025 · 2 comments
Labels
ES|QL-ui Impacts ES|QL UI >feature priority:normal A label for assessing bug priority to be used by ES engineers :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@ioanatia
Copy link
Contributor

ioanatia commented Feb 3, 2025

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 could have a single decay function with the following signature:

decay(type, origin, scale, offset, decay, value)

For parameters:

Type: can be "linear", "exp" or "gauss".
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 3 different decay functions decay_linear, decay_exp and decay_gauss.

@ioanatia ioanatia added :Search Relevance/Search Catch all for Search Relevance >feature Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch labels Feb 3, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@ioanatia ioanatia mentioned this issue Jan 23, 2025
97 tasks
@ChrisHegarty ChrisHegarty added the priority:normal A label for assessing bug priority to be used by ES engineers label Feb 6, 2025
@ioanatia ioanatia added the ES|QL-ui Impacts ES|QL UI label Mar 19, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/kibana-esql (ES|QL-ui)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ES|QL-ui Impacts ES|QL UI >feature priority:normal A label for assessing bug priority to be used by ES engineers :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

3 participants