Skip to content

Commit 14d763b

Browse files
committed
fixed info, test fixes
1 parent 2e0c9d6 commit 14d763b

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

docs/reference/query-languages/esql/_snippets/functions/appendix/values.md

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/query-languages/esql/kibana/definition/functions/values.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.

docs/reference/query-languages/esql/kibana/docs/functions/values.md

Lines changed: 2 additions & 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/main/java/org/elasticsearch/xpack/esql/expression/function/fulltext/ScoreFunction.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
import java.io.IOException;
3131
import java.util.List;
3232

33+
/**
34+
* A function to be used to score specific portions of an ES|QL query e.g., in conjunction with
35+
* an {@link org.elasticsearch.xpack.esql.plan.logical.Eval}.
36+
*/
3337
public class ScoreFunction extends Function implements EvaluatorMapper {
3438

3539
public static final NamedWriteableRegistry.Entry ENTRY = new NamedWriteableRegistry.Entry(
@@ -44,7 +48,7 @@ public class ScoreFunction extends Function implements EvaluatorMapper {
4448
returnType = "double",
4549
preview = true,
4650
description = "Scores a full text function. Returns scores for all the matching docs.",
47-
examples = { @Example(file = "score-function", tag = "score-with-field") }
51+
examples = { @Example(file = "score-function", tag = "score-single") }
4852
)
4953
public ScoreFunction(
5054
Source source,
@@ -69,7 +73,7 @@ public Expression replaceChildren(List<Expression> newChildren) {
6973

7074
@Override
7175
protected NodeInfo<? extends Expression> info() {
72-
return NodeInfo.create(this, ScoreFunction::new, children());
76+
return NodeInfo.create(this, ScoreFunction::new, children().getFirst());
7377
}
7478

7579
@Override
@@ -79,11 +83,8 @@ public String getWriteableName() {
7983

8084
@Override
8185
public EvalOperator.ExpressionEvaluator.Factory toEvaluator(EvaluatorMapper.ToEvaluator toEvaluator) {
82-
8386
ScoreOperator.ExpressionScorer.Factory scorerFactory = ScoreMapper.toScorer(children().getFirst(), toEvaluator.shardContexts());
84-
8587
return driverContext -> new ScorerEvaluatorFactory(scorerFactory).get(driverContext);
86-
8788
}
8889

8990
@Override

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,12 +1369,18 @@ public void testKqlFunctionsNotAllowedAfterCommands() throws Exception {
13691369
}
13701370

13711371
public void testQueryStringFunctionOnlyAllowedInWhere() throws Exception {
1372-
assertEquals("1:9: [QSTR] function is only supported in WHERE and STATS commands, or in EVAL within score(.) function", error("row a = qstr(\"Anna\")"));
1372+
assertEquals(
1373+
"1:9: [QSTR] function is only supported in WHERE and STATS commands, or in EVAL within score(.) function",
1374+
error("row a = qstr(\"Anna\")")
1375+
);
13731376
checkFullTextFunctionsOnlyAllowedInWhere("QSTR", "qstr(\"Anna\")", "function");
13741377
}
13751378

13761379
public void testKqlFunctionOnlyAllowedInWhere() throws Exception {
1377-
assertEquals("1:9: [KQL] function is only supported in WHERE and STATS commands, or in EVAL within score(.) function", error("row a = kql(\"Anna\")"));
1380+
assertEquals(
1381+
"1:9: [KQL] function is only supported in WHERE and STATS commands, or in EVAL within score(.) function",
1382+
error("row a = kql(\"Anna\")")
1383+
);
13781384
checkFullTextFunctionsOnlyAllowedInWhere("KQL", "kql(\"Anna\")", "function");
13791385
}
13801386

@@ -1394,11 +1400,19 @@ public void testMatchOperatornOnlyAllowedInWhere() throws Exception {
13941400
private void checkFullTextFunctionsOnlyAllowedInWhere(String functionName, String functionInvocation, String functionType)
13951401
throws Exception {
13961402
assertEquals(
1397-
"1:22: [" + functionName + "] " + functionType + " is only supported in WHERE and STATS commands, or in EVAL within score(.) function",
1403+
"1:22: ["
1404+
+ functionName
1405+
+ "] "
1406+
+ functionType
1407+
+ " is only supported in WHERE and STATS commands, or in EVAL within score(.) function",
13981408
error("from test | eval y = " + functionInvocation)
13991409
);
14001410
assertEquals(
1401-
"1:18: [" + functionName + "] " + functionType + " is only supported in WHERE and STATS commands, or in EVAL within score(.) function",
1411+
"1:18: ["
1412+
+ functionName
1413+
+ "] "
1414+
+ functionType
1415+
+ " is only supported in WHERE and STATS commands, or in EVAL within score(.) function",
14021416
error("from test | sort " + functionInvocation + " asc")
14031417
);
14041418
assertEquals(

0 commit comments

Comments
 (0)