Skip to content

Commit 48f38e5

Browse files
authored
ES|QL: Enable score function in release builds (#136988)
1 parent d1c3d6e commit 48f38e5

File tree

14 files changed

+19
-41
lines changed

14 files changed

+19
-41
lines changed

docs/changelog/136988.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 136988
2+
summary: Enable score function in release builds
3+
area: ES|QL
4+
type: feature
5+
issues: []

docs/reference/query-languages/esql/_snippets/functions/layout/score.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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ for information on the limitations of full text search.
5353
:::{include} ../_snippets/functions/layout/qstr.md
5454
:::
5555

56+
:::{include} ../_snippets/functions/layout/score.md
57+
:::
58+
5659
% TERM is currently a hidden feature
5760
% To make it visible again, uncomment this and the line in
5861
lists/search-functions.md

docs/reference/query-languages/esql/kibana/definition/functions/score.json

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

x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/plugin/ScoreFunctionIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.elasticsearch.plugins.Plugin;
1515
import org.elasticsearch.xpack.esql.VerificationException;
1616
import org.elasticsearch.xpack.esql.action.AbstractEsqlIntegTestCase;
17-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1817
import org.elasticsearch.xpack.kql.KqlPlugin;
1918
import org.junit.Before;
2019

@@ -30,7 +29,6 @@ public class ScoreFunctionIT extends AbstractEsqlIntegTestCase {
3029

3130
@Before
3231
public void setupIndex() {
33-
assumeTrue("can run this only when score() function is enabled", EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled());
3432
createAndPopulateIndex();
3533
}
3634

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
@@ -1123,7 +1123,7 @@ public enum Cap {
11231123
/**
11241124
* score function
11251125
*/
1126-
SCORE_FUNCTION(Build.current().isSnapshot()),
1126+
SCORE_FUNCTION,
11271127

11281128
/**
11291129
* Support for the SAMPLE command

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ private static FunctionDefinition[][] functions() {
526526
def(Match.class, tri(Match::new), "match"),
527527
def(MultiMatch.class, MultiMatch::new, "multi_match"),
528528
def(QueryString.class, bi(QueryString::new), "qstr"),
529-
def(MatchPhrase.class, tri(MatchPhrase::new), "match_phrase") },
529+
def(MatchPhrase.class, tri(MatchPhrase::new), "match_phrase"),
530+
def(Score.class, uni(Score::new), "score") },
530531
// time-series functions
531532
new FunctionDefinition[] {
532533
defTS(Rate.class, Rate::new, "rate"),
@@ -559,7 +560,6 @@ private static FunctionDefinition[][] snapshotFunctions() {
559560
def(Delay.class, Delay::new, "delay"),
560561
def(First.class, bi(First::new), "first"),
561562
def(Last.class, bi(Last::new), "last"),
562-
def(Score.class, uni(Score::new), Score.NAME),
563563
def(Term.class, bi(Term::new), "term"),
564564
def(CosineSimilarity.class, CosineSimilarity::new, "v_cosine"),
565565
def(DotProduct.class, DotProduct::new, "v_dot_product"),

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import org.elasticsearch.compute.operator.ScoreOperator;
1616
import org.elasticsearch.index.IndexMode;
1717
import org.elasticsearch.index.query.QueryBuilder;
18-
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1918
import org.elasticsearch.xpack.esql.capabilities.PostAnalysisPlanVerificationAware;
2019
import org.elasticsearch.xpack.esql.capabilities.PostOptimizationPlanVerificationAware;
2120
import org.elasticsearch.xpack.esql.capabilities.PostOptimizationVerificationAware;
@@ -211,8 +210,7 @@ private static void checkFullTextQueryFunctions(LogicalPlan plan, Failures failu
211210
failures.add(
212211
fail(
213212
ftf,
214-
"[{}] {} is only supported in WHERE and STATS commands"
215-
+ (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled() ? ", or in EVAL within score(.) function" : ""),
213+
"[{}] {} is only supported in WHERE and STATS commands or in EVAL within score(.) function",
216214
ftf.functionName(),
217215
ftf.functionType()
218216
)

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
@@ -25,13 +25,11 @@ public static List<NamedWriteableRegistry.Entry> getNamedWriteables() {
2525
entries.add(MultiMatch.ENTRY);
2626
entries.add(Kql.ENTRY);
2727
entries.add(MatchPhrase.ENTRY);
28+
entries.add(Score.ENTRY);
2829

2930
if (EsqlCapabilities.Cap.TERM_FUNCTION.isEnabled()) {
3031
entries.add(Term.ENTRY);
3132
}
32-
if (EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled()) {
33-
entries.add(Score.ENTRY);
34-
}
3533
if (EsqlCapabilities.Cap.DECAY_FUNCTION.isEnabled()) {
3634
entries.add(Decay.ENTRY);
3735
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class Score extends Function implements EvaluatorMapper {
4747
@FunctionInfo(
4848
returnType = "double",
4949
preview = true,
50-
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.DEVELOPMENT) },
50+
appliesTo = { @FunctionAppliesTo(lifeCycle = FunctionAppliesToLifecycle.PREVIEW, version = "9.3.0") },
5151
description = "Scores an expression. Only full text functions will be scored. Returns scores for all the resulting docs.",
5252
examples = { @Example(file = "score-function", tag = "score-function") }
5353
)

0 commit comments

Comments
 (0)