diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-09-29 14:00:14 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-09-29 14:24:52 +0000 |
commit | ac6ceebe1e74f9c38e0a7d57f40d4177622cbd14 (patch) | |
tree | c59e4b22aab968fcc73d08164167458fab28d725 /searchlib | |
parent | 5a5ea56ae3eec1ed8e69048f0703e7da6a1d6cb8 (diff) |
If there is a single child in the ws, that also is a leaf, it will be be lifted out directly.
Diffstat (limited to 'searchlib')
3 files changed, 19 insertions, 5 deletions
diff --git a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp index ec610d20928..bcde2f22a07 100644 --- a/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp +++ b/searchlib/src/tests/queryeval/weighted_set_term/weighted_set_term_test.cpp @@ -167,7 +167,7 @@ void run_simple(bool field_is_filter, bool term_is_not_needed, bool singleTerm) } WS ws; if (singleTerm) { - ws.add("3", 30).add("100", 1000); + ws.add("3", 30); } else { ws.add("7", 70).add("5", 50).add("3", 30).add("100", 1000); } @@ -197,6 +197,10 @@ TEST("testSimple unranked") { TEST_DO(run_simple(false, true, false)); } +TEST("testSimple unranked filter filed") { + TEST_DO(run_simple(true, true, false)); +} + TEST("testSimple single") { TEST_DO(run_simple(false, false, true)); } @@ -209,6 +213,10 @@ TEST("testSimple single unranked") { TEST_DO(run_simple(false, true, true)); } +TEST("testSimple single unranked filter field") { + TEST_DO(run_simple(true, true, true)); +} + void run_multi(bool field_is_filter, bool term_is_not_needed) { FakeSearchable index; diff --git a/searchlib/src/vespa/searchlib/queryeval/blueprint.h b/searchlib/src/vespa/searchlib/queryeval/blueprint.h index 882db00c059..3dd20d73373 100644 --- a/searchlib/src/vespa/searchlib/queryeval/blueprint.h +++ b/searchlib/src/vespa/searchlib/queryeval/blueprint.h @@ -26,6 +26,7 @@ namespace search::queryeval { class SearchIterator; class ExecuteInfo; class MatchingElementsSearch; +class LeafBlueprint; /** * A Blueprint is an intermediate representation of a search. More @@ -251,7 +252,7 @@ public: virtual bool isEquiv() const { return false; } virtual bool isWhiteList() const { return false; } virtual bool isIntermediate() const { return false; } - virtual bool isLeaf() const { return false; } + virtual LeafBlueprint * asLeaf() noexcept { return nullptr; } virtual bool isAnd() const { return false; } virtual bool isAndNot() const { return false; } virtual bool isOr() const { return false; } @@ -397,7 +398,7 @@ public: void fetchPostings(const ExecuteInfo &execInfo) override; void freeze() final; SearchIteratorUP createSearch(fef::MatchData &md, bool strict) const override; - bool isLeaf() const final { return true; } + LeafBlueprint * asLeaf() noexcept final { return this; } virtual bool getRange(vespalib::string & from, vespalib::string & to) const; virtual SearchIteratorUP createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool strict) const = 0; diff --git a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp index f09ad4103d8..d7b98f6b006 100644 --- a/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp +++ b/searchlib/src/vespa/searchlib/queryeval/weighted_set_term_blueprint.cpp @@ -96,8 +96,13 @@ SearchIterator::UP WeightedSetTermBlueprint::createLeafSearch(const fef::TermFieldMatchDataArray &tfmda, bool) const { assert(tfmda.size() == 1); - if ((_terms.size() == 1) && tfmda[0]->isNotNeeded() && _terms[0]->isLeaf()) { - return static_cast<LeafBlueprint &>(*_terms[0]).createLeafSearch(tfmda, true); + if ((_terms.size() == 1) && tfmda[0]->isNotNeeded()) { + LeafBlueprint * leaf = _terms[0]->asLeaf(); + if (leaf != nullptr) { + // Always returnin a strict iterator independently of what was required, + // as that is what we do with all the children when there are more. + return leaf->createLeafSearch(tfmda, true); + } } fef::MatchData::UP md = _layout.createMatchData(); std::vector<SearchIterator*> children; |