diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-11-27 13:28:22 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-11-27 13:28:22 +0100 |
commit | c3ec1a4e8c2235988685a51cd43aa2404a2bbdd2 (patch) | |
tree | 3fce85e678d92f75bd1dcb8e7928b595af3e27fc /searchlib/src/tests/attribute | |
parent | dc0d58d0215a3fb91851eece9d9911d450fbe2f7 (diff) |
Create weighted set blueprints for InTerm.
Diffstat (limited to 'searchlib/src/tests/attribute')
-rw-r--r-- | searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp | 34 | ||||
-rw-r--r-- | searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp | 17 |
2 files changed, 51 insertions, 0 deletions
diff --git a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp index 9ed28a7714c..8831bd1ec75 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp @@ -20,6 +20,7 @@ #include <vespa/searchlib/query/tree/predicate_query_term.h> #include <vespa/searchlib/query/tree/rectangle.h> #include <vespa/searchlib/query/tree/simplequery.h> +#include <vespa/searchlib/query/tree/string_term_vector.h> #include <vespa/searchlib/query/weight.h> #include <vespa/searchlib/queryeval/blueprint.h> #include <vespa/searchlib/queryeval/fake_requestcontext.h> @@ -56,6 +57,8 @@ using search::query::SimpleSubstringTerm; using search::query::SimpleStringTerm; using search::query::SimpleWandTerm; using search::query::SimpleWeightedSetTerm; +using search::query::SimpleInTerm; +using search::query::StringTermVector; using search::query::Weight; using search::queryeval::Blueprint; using search::queryeval::FieldSpec; @@ -587,6 +590,37 @@ TEST("require that attribute weighted set term works") { } } +TEST("require that attribute in term works") { + for (int i = 0; i <= 0x3; ++i) { + bool fast_search = ((i & 0x1) != 0); + bool strict = ((i & 0x2) != 0); + MyAttributeManager attribute_manager = make_weighted_string_attribute_manager(fast_search); + auto stv = std::make_unique<StringTermVector>(4); + stv->addTerm("foo"); + stv->addTerm("bar"); + stv->addTerm("baz"); + stv->addTerm("fox"); + SimpleInTerm node(std::move(stv), SimpleInTerm::Type::STRING, field, 0, Weight(1)); + Result result = do_search(attribute_manager, node, strict); + EXPECT_FALSE(result.est_empty); + ASSERT_EQUAL(5u, result.hits.size()); + if (fast_search && result.iterator_dump.find("MonitoringDumpIterator") == vespalib::string::npos) { + fprintf(stderr, "DUMP: %s\n", result.iterator_dump.c_str()); + EXPECT_TRUE(result.iterator_dump.find("PostingIteratorPack") != vespalib::string::npos); + } + EXPECT_EQUAL(10u, result.hits[0].docid); + EXPECT_EQUAL(1, result.hits[0].match_weight); + EXPECT_EQUAL(20u, result.hits[1].docid); + EXPECT_EQUAL(1, result.hits[1].match_weight); + EXPECT_EQUAL(30u, result.hits[2].docid); + EXPECT_EQUAL(1, result.hits[2].match_weight); + EXPECT_EQUAL(40u, result.hits[3].docid); + EXPECT_EQUAL(1, result.hits[3].match_weight); + EXPECT_EQUAL(50u, result.hits[4].docid); + EXPECT_EQUAL(1, result.hits[4].match_weight); + } +} + TEST("require that predicate query in non-predicate field yields empty.") { MyAttributeManager attribute_manager = makeAttributeManager("foo"); diff --git a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp index 39869340cea..50f7d170afc 100644 --- a/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attributeblueprint_test.cpp @@ -14,6 +14,7 @@ #include <vespa/searchlib/query/tree/location.h> #include <vespa/searchlib/query/tree/point.h> #include <vespa/searchlib/query/tree/simplequery.h> +#include <vespa/searchlib/query/tree/string_term_vector.h> #include <vespa/searchlib/queryeval/fake_requestcontext.h> #include <vespa/searchlib/queryeval/filter_wrapper.h> #include <vespa/searchlib/queryeval/leaf_blueprints.h> @@ -41,6 +42,8 @@ using search::query::SimplePrefixTerm; using search::query::SimpleStringTerm; using search::query::SimpleWandTerm; using search::query::SimpleWeightedSetTerm; +using search::query::SimpleInTerm; +using search::query::StringTermVector; using search::query::Weight; using search::queryeval::Blueprint; using search::queryeval::EmptyBlueprint; @@ -452,6 +455,13 @@ TEST(AttributeBlueprintTest, direct_weighted_set_blueprint_creates_or_like_filte term.addTerm("bar", Weight(20)); f.expect_filter_search(SimpleResult({1, 3}), term); } + { + auto stv = std::make_unique<StringTermVector>(2); + stv->addTerm("foo"); + stv->addTerm("bar"); + SimpleInTerm term(std::move(stv), SimpleInTerm::Type::STRING, field, 0, Weight(0)); + f.expect_filter_search(SimpleResult({1, 3}), term); + } } TEST(AttributeBlueprintTest, attribute_weighted_set_blueprint_creates_or_like_filter_search) @@ -463,6 +473,13 @@ TEST(AttributeBlueprintTest, attribute_weighted_set_blueprint_creates_or_like_fi term.addTerm("bar", Weight(20)); f.expect_filter_search(SimpleResult({1, 3}), term); } + { + auto stv = std::make_unique<StringTermVector>(2); + stv->addTerm("foo"); + stv->addTerm("bar"); + SimpleInTerm term(std::move(stv), SimpleInTerm::Type::STRING, field, 0, Weight(0)); + f.expect_filter_search(SimpleResult({1, 3}), term); + } } GTEST_MAIN_RUN_ALL_TESTS() |