Skip to content

Commit d70093b

Browse files
authored
ScoreTests capability check (elastic#131516)
1 parent 439b8e6 commit d70093b

File tree

3 files changed

+9
-18
lines changed
  • docs/reference/query-languages/esql
  • x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext

3 files changed

+9
-18
lines changed

docs/reference/query-languages/esql/_snippets/functions/parameters/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/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/test/java/org/elasticsearch/xpack/esql/expression/function/fulltext/ScoreTests.java

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,29 @@
1010
import com.carrotsearch.randomizedtesting.annotations.Name;
1111
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
1212

13+
import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
1314
import org.elasticsearch.xpack.esql.core.expression.Expression;
1415
import org.elasticsearch.xpack.esql.core.tree.Source;
1516
import org.elasticsearch.xpack.esql.expression.function.FunctionName;
1617
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
17-
import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
18+
import org.junit.BeforeClass;
1819

1920
import java.util.ArrayList;
2021
import java.util.List;
2122
import java.util.function.Supplier;
2223

23-
import static org.elasticsearch.xpack.esql.SerializationTestUtils.serializeDeserialize;
2424
import static org.elasticsearch.xpack.esql.core.type.DataType.BOOLEAN;
2525
import static org.elasticsearch.xpack.esql.core.type.DataType.DOUBLE;
2626
import static org.hamcrest.Matchers.equalTo;
2727

2828
@FunctionName("score")
2929
public class ScoreTests extends AbstractMatchFullTextFunctionTests {
3030

31+
@BeforeClass
32+
public static void init() {
33+
assumeTrue("can run this only when score() function is enabled", EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled());
34+
}
35+
3136
public ScoreTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testCaseSupplier) {
3237
this.testCase = testCaseSupplier.get();
3338
}
@@ -55,18 +60,4 @@ protected Expression build(Source source, List<Expression> args) {
5560
return new Score(source, args.getFirst());
5661
}
5762

58-
/**
59-
* Copy of the overridden method that doesn't check for children size, as the {@code options} child isn't serialized in Match.
60-
*/
61-
@Override
62-
protected Expression serializeDeserializeExpression(Expression expression) {
63-
Expression newExpression = serializeDeserialize(
64-
expression,
65-
PlanStreamOutput::writeNamedWriteable,
66-
in -> in.readNamedWriteable(Expression.class),
67-
testCase.getConfiguration() // The configuration query should be == to the source text of the function for this to work
68-
);
69-
// Fields use synthetic sources, which can't be serialized. So we use the originals instead.
70-
return newExpression.replaceChildren(expression.children());
71-
}
7263
}

0 commit comments

Comments
 (0)