Skip to content

Commit c7d4af4

Browse files
authored
ES|QL: Release decay function (#137830)
1 parent 763332e commit c7d4af4

File tree

9 files changed

+13
-26
lines changed

9 files changed

+13
-26
lines changed

docs/changelog/137830.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 137830
2+
summary: Release decay function
3+
area: ES|QL
4+
type: feature
5+
issues: []

docs/reference/query-languages/esql/_snippets/functions/layout/decay.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/functions-operators/search-functions.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ including [KNN](dense-vector-functions.md#esql-knn), please refer to
2020
the [Dense vector functions](dense-vector-functions.md) documentation.
2121
:::
2222

23-
Use these functions for [full-text search](docs-content://solutions/search/full-text.md)
23+
Use these functions for [full-text search](docs-content://solutions/search/full-text.md)
2424
and [semantic search](docs-content://solutions/search/semantic-search/semantic-search-semantic-text.md).
2525

2626
Full text functions can be used to
@@ -56,14 +56,11 @@ for information on the limitations of full text search.
5656
:::{include} ../_snippets/functions/layout/score.md
5757
:::
5858

59+
:::{include} ../_snippets/functions/layout/decay.md
60+
:::
61+
5962
% TERM is currently a hidden feature
6063
% To make it visible again, uncomment this and the line in
6164
lists/search-functions.md
6265
% :::{include} ../_snippets/functions/layout/term.md
6366
% :::
64-
65-
% DECAY is currently a hidden feature
66-
% To make it visible again, uncomment this and the line in
67-
lists/search-functions.md
68-
% :::{include} ../_snippets/functions/layout/decay.md
69-
% :::

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/action/EsqlCapabilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1351,7 +1351,7 @@ public enum Cap {
13511351
/**
13521352
* Decay function for custom scoring
13531353
*/
1354-
DECAY_FUNCTION(Build.current().isSnapshot()),
1354+
DECAY_FUNCTION,
13551355

13561356
/**
13571357
* FIRST and LAST aggregate functions.

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/FullTextWritables.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
2626
entries.add(Kql.ENTRY);
2727
entries.add(MatchPhrase.ENTRY);
2828
entries.add(Score.ENTRY);
29+
entries.add(Decay.ENTRY);
2930

3031
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
3132
entries.add(Term.ENTRY);
3233
}
33-
if (EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled()) {
34-
entries.add(Decay.ENTRY);
35-
}
3634

3735
return Collections.unmodifiableList(entries);
3836
}

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/Decay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public class Decay extends EsqlScalarFunction implements OptionalArgument, PostO
124124
@FunctionInfo(
125125
returnType = "double",
126126
preview = true,
127-
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.PREVIEW, version = "9.2.0") },
127+
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.PREVIEW, version = "9.3.0") },
128128
description = "Calculates a relevance score that decays based on the distance of a numeric, spatial or date type value "
129129
+ "from a target origin, using configurable decay functions.",
130130
detailedDescription = """

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/analysis/VerifierTests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2639,8 +2639,6 @@ public void testFullTextFunctionsInStats() {
26392639
}
26402640

26412641
public void testDecayArgs() {
2642-
assumeTrue("Decay function not enabled", EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled());
2643-
26442642
// First arg cannot be null
26452643
assertEquals(
26462644
"2:23: first argument of [decay(null, origin, scale, "

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/score/DecayTests.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.elasticsearch.common.geo.GeoPoint;
1414
import org.elasticsearch.common.unit.DistanceUnit;
1515
import org.elasticsearch.script.ScoreScriptUtils;
16-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1716
import org.elasticsearch.xpack.esql.core.expression.Expression;
1817
import org.elasticsearch.xpack.esql.core.expression.Literal;
1918
import org.elasticsearch.xpack.esql.core.expression.MapExpression;
@@ -22,7 +21,6 @@
2221
import org.elasticsearch.xpack.esql.expression.function.AbstractScalarFunctionTestCase;
2322
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
2423
import org.hamcrest.Matcher;
25-
import org.junit.BeforeClass;
2624

2725
import java.math.BigDecimal;
2826
import java.math.RoundingMode;
@@ -49,11 +47,6 @@ public DecayTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testCase
4947
this.testCase = testCaseSupplier.get();
5048
}
5149

52-
@BeforeClass
53-
public static void checkCapability() {
54-
assumeTrue("Decay function tests require the DECAY_FUNCTION capability", EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled());
55-
}
56-
5750
@ParametersFactory
5851
public static Iterable<Object[]> parameters() {
5952
List<TestCaseSupplier> testCaseSuppliers = new ArrayList<>();

x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/optimizer/LogicalPlanOptimizerTests.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9337,8 +9337,6 @@ public void testTranslateMetricsGroupedByTBucketInTSMode() {
93379337
}
93389338

93399339
public void testDecayOriginMustBeLiteral() {
9340-
assumeTrue("requires DECAY_FUNCTION capability enabled", EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled());
9341-
93429340
var query = """
93439341
FROM employees
93449342
| EVAL decay_result = decay(salary, salary, 10, {"offset": 5, "decay": 0.5, "type": "linear"})
@@ -9353,8 +9351,6 @@ public void testDecayOriginMustBeLiteral() {
93539351
}
93549352

93559353
public void testDecayScaleMustBeLiteral() {
9356-
assumeTrue("requires DECAY_FUNCTION capability enabled", EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled());
9357-
93589354
var query = """
93599355
FROM employees
93609356
| EVAL decay_result = decay(salary, 10, salary, {"offset": 5, "decay": 0.5, "type": "linear"})

0 commit comments

Comments
 (0)