diff options
Diffstat (limited to 'searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp')
-rw-r--r-- | searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp index 421ebffafa4..20b9e1206c7 100644 --- a/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp +++ b/searchcore/src/tests/proton/matching/index_environment/index_environment_test.cpp @@ -3,6 +3,7 @@ #include <vespa/eval/eval/value_cache/constant_value.h> #include <vespa/searchcore/proton/matching/indexenvironment.h> +#include <vespa/searchcore/proton/matching/ranking_expressions.h> using namespace proton::matching; using search::fef::FieldInfo; @@ -15,6 +16,21 @@ using search::index::schema::DataType; using vespalib::eval::ConstantValue; using SIAF = Schema::ImportedAttributeField; +const vespalib::string my_expr_ref( + "this is my reference ranking expression.\n" + "this is my reference ranking expression.\n" + "it will not compile into a function.\n" + "it will not compile into a function.\n" + "it is just some text, that can also be compressed...\n" + "it is just some text, that can also be compressed...\n"); + +RankingExpressions make_expressions() { + RankingExpressions expr_list; + expr_list.add("expr1", TEST_PATH("my_expr")); + expr_list.add("expr2", TEST_PATH("my_expr.lz4")); + return expr_list; +} + OnnxModels make_models() { OnnxModels::Vector list; list.emplace_back(OnnxModel("model1", "path1").input_feature("input1","feature1").output_name("output1", "out1")); @@ -50,7 +66,7 @@ struct Fixture { Fixture(Schema::UP schema_) : repo(), schema(std::move(schema_)), - env(7, *schema, Properties(), repo, make_models()) + env(7, *schema, Properties(), repo, make_expressions(), make_models()) { } const FieldInfo *assertField(size_t idx, @@ -123,4 +139,13 @@ TEST_F("require that onnx model config can be obtained", Fixture(buildEmptySchem EXPECT_TRUE(f1.env.getOnnxModel("model3") == nullptr); } +TEST_F("require that external ranking expressions can be obtained", Fixture(buildEmptySchema())) { + auto expr1 = f1.env.getRankingExpression("expr1"); + auto expr2 = f1.env.getRankingExpression("expr2"); + auto expr3 = f1.env.getRankingExpression("expr3"); + EXPECT_EQUAL(expr1, my_expr_ref); + EXPECT_EQUAL(expr2, my_expr_ref); + EXPECT_TRUE(expr3.empty()); +} + TEST_MAIN() { TEST_RUN_ALL(); } |