diff options
author | Henning Baldersheim <balder@oath.com> | 2018-04-03 13:52:54 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-04-03 13:52:54 +0200 |
commit | 9e70b2520ace7245a949553f9f92646db910b804 (patch) | |
tree | 5f6b3f8e317f5ddf2ab2e7a5263164d3f7d00732 /searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp | |
parent | 3aac7bad02036393444a9fedd930be9f08c65a8a (diff) |
Add test to prove that the filter aspect is correctly handled also for the DirectAttributeBlueprint
Diffstat (limited to 'searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp')
-rw-r--r-- | searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp | 23 |
1 files changed, 22 insertions, 1 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 89f6bb5d88e..d8e295cb469 100644 --- a/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp +++ b/searchlib/src/tests/attribute/searchable/attribute_searchable_adapter_test.cpp @@ -370,9 +370,10 @@ void set_weights(StringAttribute *attr, uint32_t docid, attr->commit(); } -MyAttributeManager make_weighted_string_attribute_manager(bool fast_search) { +MyAttributeManager make_weighted_string_attribute_manager(bool fast_search, bool isFilter = false) { Config cfg(BasicType::STRING, CollectionType::WSET); cfg.setFastSearch(fast_search); + cfg.setIsFilter(isFilter); AttributeVector::SP attr_ptr = AttributeFactory::createAttribute(field, cfg); StringAttribute *attr = static_cast<StringAttribute *>(attr_ptr.get()); add_docs(attr, num_docs); @@ -463,6 +464,26 @@ TEST("require that direct attribute iterators work") { } } +TEST("require that single weighted set turns filter on filter fields") { + bool fast_search = true; + bool strict = true; + bool isFilter = true; + MyAttributeManager attribute_manager = make_weighted_string_attribute_manager(fast_search, isFilter); + SimpleStringTerm empty_node("notfoo", "", 0, Weight(1)); + Result empty_result = do_search(attribute_manager, empty_node, strict); + EXPECT_EQUAL(0u, empty_result.hits.size()); + SimpleStringTerm node("foo", "", 0, Weight(1)); + Result result = do_search(attribute_manager, node, strict); + EXPECT_EQUAL(3u, result.est_hits); + EXPECT_TRUE(result.iterator_dump.find("DocumentWeightSearchIterator") == vespalib::string::npos); + EXPECT_TRUE(result.iterator_dump.find("FilterAttributePostingListIteratorT") == vespalib::string::npos); + ASSERT_EQUAL(3u, result.hits.size()); + EXPECT_FALSE(result.est_empty); + EXPECT_EQUAL(20u, result.hits[0].docid); + EXPECT_EQUAL(40u, result.hits[1].docid); + EXPECT_EQUAL(50u, result.hits[2].docid); +} + const char *as_str(bool flag) { return flag? "true" : "false"; } TEST("require that attribute parallel wand works") { |