diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-10-25 16:24:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-25 16:24:04 +0200 |
commit | 55151325ae7a3547bd18777b75451998c41f1cbf (patch) | |
tree | 16568368d6a8e14a7845dc071c630b278f4689a0 /searchlib | |
parent | 1080e4d9d60e00930ac2f3241c48aee25c66316b (diff) | |
parent | 1a5ab72fc6e45d7f30ecfa35d18bbe3dfb1f799b (diff) |
Merge pull request #24579 from vespa-engine/toregge/verify-that-single-dictionary-entry-from-lookup-range-is-a-match
Verify that single dictionary entry from lookupRange() is a match.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp | 15 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h | 10 |
2 files changed, 15 insertions, 10 deletions
diff --git a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp index 4d02ea7f61d..b6aaadd08cc 100644 --- a/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp +++ b/searchlib/src/tests/attribute/searchcontext/searchcontext_test.cpp @@ -21,6 +21,7 @@ #include <vespa/vespalib/util/compress.h> #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/stllike/asciistream.h> +#include <initializer_list> #include <set> #include <vespa/log/log.h> @@ -71,6 +72,7 @@ class DocSet : public std::set<uint32_t> public: DocSet() noexcept; ~DocSet(); + DocSet(std::initializer_list<uint32_t> l) : std::set<uint32_t>(l) { } DocSet(const uint32_t *b, const uint32_t *e) : std::set<uint32_t>(b, e) {} DocSet & put(const uint32_t &v) { insert(v); @@ -1398,7 +1400,7 @@ SearchContextTest::testRegexSearch(const AttributePtr & ptr) addDocs(*ptr.get(), numDocs); const char * strings [] = {"abc1def", "abc2Def", "abc2def", "abc4def", "abc5def", "abc6def"}; - std::vector<const char *> terms = { "abc", "bc2de" }; + std::vector<const char *> terms = { "abc", "bc2de", "^abc1def.*bar" }; for (uint32_t doc = 1; doc < numDocs + 1; ++doc) { ASSERT_TRUE(doc < vec.getNumDocs()); @@ -1409,14 +1411,9 @@ SearchContextTest::testRegexSearch(const AttributePtr & ptr) std::vector<DocSet> expected; DocSet empty; - { - uint32_t docs[] = {1, 2, 3, 4, 5, 6}; - expected.emplace_back(docs, docs + 6); // "abc" - } - { - uint32_t docs[] = {2, 3}; - expected.emplace_back(docs, docs + 2); // "bc2de" - } + expected.emplace_back(DocSet{1, 2, 3, 4, 5, 6}); // "abc" + expected.emplace_back(DocSet{2, 3}); // "bc2de" + expected.emplace_back(empty); // "^abc1def.*bar" for (uint32_t i = 0; i < terms.size(); ++i) { performSearch(vec, terms[i], expected[i], TermType::REGEXP); diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h index 40682002818..8e10c8b0967 100644 --- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h +++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h @@ -287,7 +287,15 @@ StringPostingSearchContext(BaseSC&& base_sc, bool useBitVector, const AttrT &toB this->lookupTerm(comp); } if (this->_uniqueValues == 1u) { - this->lookupSingle(); + /* + * A single dictionary entry from lookupRange() might not be + * a match if this is a regex search or a fuzzy search. + */ + if (!this->_lowerDictItr.valid() || useThis(this->_lowerDictItr)) { + this->lookupSingle(); + } else { + this->_uniqueValues = 0; + } } } } |