|
@@ -10,17 +10,17 @@ package org.elasticsearch.xpack.esql.expression.function.fulltext;
|
|
|
import com.carrotsearch.randomizedtesting.annotations.Name;
|
|
|
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
|
|
|
|
|
|
+import org.elasticsearch.xpack.esql.action.EsqlCapabilities;
|
|
|
import org.elasticsearch.xpack.esql.core.expression.Expression;
|
|
|
import org.elasticsearch.xpack.esql.core.tree.Source;
|
|
|
import org.elasticsearch.xpack.esql.expression.function.FunctionName;
|
|
|
import org.elasticsearch.xpack.esql.expression.function.TestCaseSupplier;
|
|
|
-import org.elasticsearch.xpack.esql.io.stream.PlanStreamOutput;
|
|
|
+import org.junit.BeforeClass;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.function.Supplier;
|
|
|
|
|
|
-import static org.elasticsearch.xpack.esql.SerializationTestUtils.serializeDeserialize;
|
|
|
import static org.elasticsearch.xpack.esql.core.type.DataType.BOOLEAN;
|
|
|
import static org.elasticsearch.xpack.esql.core.type.DataType.DOUBLE;
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
@@ -28,6 +28,11 @@ import static org.hamcrest.Matchers.equalTo;
|
|
|
@FunctionName("score")
|
|
|
public class ScoreTests extends AbstractMatchFullTextFunctionTests {
|
|
|
|
|
|
+ @BeforeClass
|
|
|
+ public static void init() {
|
|
|
+ assumeTrue("can run this only when score() function is enabled", EsqlCapabilities.Cap.SCORE_FUNCTION.isEnabled());
|
|
|
+ }
|
|
|
+
|
|
|
public ScoreTests(@Name("TestCase") Supplier<TestCaseSupplier.TestCase> testCaseSupplier) {
|
|
|
this.testCase = testCaseSupplier.get();
|
|
|
}
|
|
@@ -55,18 +60,4 @@ public class ScoreTests extends AbstractMatchFullTextFunctionTests {
|
|
|
return new Score(source, args.getFirst());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Copy of the overridden method that doesn't check for children size, as the {@code options} child isn't serialized in Match.
|
|
|
- */
|
|
|
- @Override
|
|
|
- protected Expression serializeDeserializeExpression(Expression expression) {
|
|
|
- Expression newExpression = serializeDeserialize(
|
|
|
- expression,
|
|
|
- PlanStreamOutput::writeNamedWriteable,
|
|
|
- in -> in.readNamedWriteable(Expression.class),
|
|
|
- testCase.getConfiguration() // The configuration query should be == to the source text of the function for this to work
|
|
|
- );
|
|
|
- // Fields use synthetic sources, which can't be serialized. So we use the originals instead.
|
|
|
- return newExpression.replaceChildren(expression.children());
|
|
|
- }
|
|
|
}
|