From 97c388081bdf51a6d086c1e51e3919d8eb427117 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 12 Jan 2024 15:38:29 +0100 Subject: Rename constants and add comment for streaming search wand term unit test. --- searchlib/src/tests/query/streaming_query_test.cpp | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'searchlib/src/tests/query/streaming_query_test.cpp') diff --git a/searchlib/src/tests/query/streaming_query_test.cpp b/searchlib/src/tests/query/streaming_query_test.cpp index 2a71fce85c3..7c4b7555158 100644 --- a/searchlib/src/tests/query/streaming_query_test.cpp +++ b/searchlib/src/tests/query/streaming_query_test.cpp @@ -960,8 +960,8 @@ TEST(StreamingQueryTest, dot_product_term) namespace { -constexpr double exp_wand_score = 13 * 27 + 4 * 2; -constexpr double exp_wand_hidden_score = 17 * 27 + 9 * 2; +constexpr double exp_wand_score_field_12 = 13 * 27 + 4 * 2; +constexpr double exp_wand_score_field_11 = 17 * 27 + 9 * 2; void check_wand_term(double limit, const vespalib::string& label) @@ -975,6 +975,12 @@ check_wand_term(double limit, const vespalib::string& label) EXPECT_EQ(2, term.get_terms().size()); term.set_score_threshold(limit); SimpleTermData td; + /* + * Search in fields 10, 11 and 12 (cf. fieldset in schema). + * Fields 11 and 12 have content for doc containing the keys. + * Fields 10 and 12 have valid handles and can be used for ranking. + * Field 11 does not have a valid handle, thus no associated match data. + */ td.addField(10); td.addField(11); td.addField(12); @@ -987,15 +993,15 @@ check_wand_term(double limit, const vespalib::string& label) auto& q1 = *term.get_terms()[1]; q1.add(0, 11, 0, 9); q1.add(0, 12, 0, 4); - EXPECT_EQ(limit < exp_wand_hidden_score, term.evaluate()); + EXPECT_EQ(limit < exp_wand_score_field_11, term.evaluate()); MatchData md(MatchData::params().numTermFields(2)); term.unpack_match_data(23, td, md); auto tmd0 = md.resolveTermField(0); EXPECT_NE(23, tmd0->getDocId()); auto tmd1 = md.resolveTermField(1); - if (limit < exp_wand_score) { + if (limit < exp_wand_score_field_12) { EXPECT_EQ(23, tmd1->getDocId()); - EXPECT_EQ(exp_wand_score, tmd1->getRawScore()); + EXPECT_EQ(exp_wand_score_field_12, tmd1->getRawScore()); } else { EXPECT_NE(23, tmd1->getDocId()); } @@ -1006,12 +1012,12 @@ check_wand_term(double limit, const vespalib::string& label) TEST(StreamingQueryTest, wand_term) { check_wand_term(0.0, "no limit"); - check_wand_term(exp_wand_score - 1, "score above limit"); - check_wand_term(exp_wand_score, "score at limit"); - check_wand_term(exp_wand_score + 1, "score below limit"); - check_wand_term(exp_wand_hidden_score - 1, "hidden score above limit"); - check_wand_term(exp_wand_hidden_score, "hidden score at limit"); - check_wand_term(exp_wand_hidden_score + 1, "hidden score below limit"); + check_wand_term(exp_wand_score_field_12 - 1, "score above limit"); + check_wand_term(exp_wand_score_field_12, "score at limit"); + check_wand_term(exp_wand_score_field_12 + 1, "score below limit"); + check_wand_term(exp_wand_score_field_11 - 1, "hidden score above limit"); + check_wand_term(exp_wand_score_field_11, "hidden score at limit"); + check_wand_term(exp_wand_score_field_11 + 1, "hidden score below limit"); } TEST(StreamingQueryTest, control_the_size_of_query_terms) -- cgit v1.2.3