diff options
author | Tor Egge <Tor.Egge@online.no> | 2024-02-06 14:38:33 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2024-02-06 14:38:33 +0100 |
commit | 624bb3303a021ab3f3065c8d2be3d399054a82cf (patch) | |
tree | 90ee218ab735fa38ac1a5cc6c9bbe8afef0d68bb | |
parent | 9ae25d8c35f7a15fdb8f45eee4ca34afe8cd483a (diff) |
Handle search::streaming::PhraseQueryNode as a leaf in the query tree.
15 files changed, 62 insertions, 263 deletions
diff --git a/searchlib/src/tests/query/streaming/phrase_query_node_test.cpp b/searchlib/src/tests/query/streaming/phrase_query_node_test.cpp index 2459fe2f01c..a6b3a1ffe05 100644 --- a/searchlib/src/tests/query/streaming/phrase_query_node_test.cpp +++ b/searchlib/src/tests/query/streaming/phrase_query_node_test.cpp @@ -34,11 +34,9 @@ TEST(PhraseQueryNodeTest, test_phrase_evaluate) vespalib::string stackDump = StackDumpCreator::create(*node); QueryNodeResultFactory empty; Query q(empty, stackDump); - QueryNodeRefList phrases; - q.getPhrases(phrases); - QueryTermList terms; - q.getLeaves(terms); - for (QueryTerm * qt : terms) { + auto& p = dynamic_cast<PhraseQueryNode&>(q.getRoot()); + auto& terms = p.get_terms(); + for (auto& qt : terms) { qt->resizeFieldId(1); } @@ -69,8 +67,7 @@ TEST(PhraseQueryNodeTest, test_phrase_evaluate) terms[1]->add(5, 0, 1, 1); terms[2]->add(5, 0, 1, 0); HitList hits; - auto * p = static_cast<PhraseQueryNode *>(phrases[0]); - p->evaluateHits(hits); + p.evaluateHits(hits); ASSERT_EQ(3u, hits.size()); EXPECT_EQ(0u, hits[0].field_id()); EXPECT_EQ(0u, hits[0].element_id()); @@ -81,7 +78,7 @@ TEST(PhraseQueryNodeTest, test_phrase_evaluate) EXPECT_EQ(3u, hits[2].field_id()); EXPECT_EQ(0u, hits[2].element_id()); EXPECT_EQ(0u, hits[2].position()); - EXPECT_TRUE(p->evaluate()); + EXPECT_TRUE(p.evaluate()); } GTEST_MAIN_RUN_ALL_TESTS() diff --git a/searchlib/src/tests/query/streaming_query_test.cpp b/searchlib/src/tests/query/streaming_query_test.cpp index cf72b71d6ad..19a2a0876c6 100644 --- a/searchlib/src/tests/query/streaming_query_test.cpp +++ b/searchlib/src/tests/query/streaming_query_test.cpp @@ -404,26 +404,20 @@ TEST(StreamingQueryTest, test_get_query_parts) QueryNodeResultFactory empty; Query q(empty, stackDump); QueryTermList terms; - QueryNodeRefList phrases; q.getLeaves(terms); - q.getPhrases(phrases); - ASSERT_TRUE(terms.size() == 7); - ASSERT_TRUE(phrases.size() == 2); - { - QueryTermList pts; - phrases[0]->getLeaves(pts); + ASSERT_TRUE(terms.size() == 4); + PhraseQueryNode* null = nullptr; + EXPECT_EQ(null, dynamic_cast<PhraseQueryNode*>(terms[0])); + EXPECT_NE(null, dynamic_cast<PhraseQueryNode*>(terms[1])); + EXPECT_EQ(null, dynamic_cast<PhraseQueryNode*>(terms[2])); + EXPECT_NE(null, dynamic_cast<PhraseQueryNode*>(terms[3])); + { + auto& pts = dynamic_cast<PhraseQueryNode&>(*terms[1]).get_terms(); ASSERT_TRUE(pts.size() == 3); - for (size_t i = 0; i < 3; ++i) { - EXPECT_EQ(pts[i], terms[i + 1]); - } } { - QueryTermList pts; - phrases[1]->getLeaves(pts); + auto& pts = dynamic_cast<PhraseQueryNode&>(*terms[3]).get_terms(); ASSERT_TRUE(pts.size() == 2); - for (size_t i = 0; i < 2; ++i) { - EXPECT_EQ(pts[i], terms[i + 5]); - } } } diff --git a/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.cpp b/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.cpp index 95781b58019..9cd8d41d33d 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.cpp +++ b/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.cpp @@ -20,46 +20,12 @@ PhraseQueryNode::evaluate() const return ! evaluateHits(hl).empty(); } -void -PhraseQueryNode::getPhrases(QueryNodeRefList & tl) -{ - tl.push_back(this); -} - -void -PhraseQueryNode::getPhrases(ConstQueryNodeRefList & tl) const -{ - tl.push_back(this); -} - -void -PhraseQueryNode::getLeaves(QueryTermList & tl) -{ - for (const auto& node : get_terms()) { - node->getLeaves(tl); - } -} - -void -PhraseQueryNode::getLeaves(ConstQueryTermList & tl) const -{ - for (const auto& node : get_terms()) { - node->getLeaves(tl); - } -} - size_t PhraseQueryNode::width() const { return get_terms().size(); } -MultiTerm* -PhraseQueryNode::as_multi_term() noexcept -{ - return nullptr; -} - const HitList & PhraseQueryNode::evaluateHits(HitList & hl) const { diff --git a/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.h b/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.h index 763cb1d6b8f..0d443ac4527 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.h +++ b/searchlib/src/vespa/searchlib/query/streaming/phrase_query_node.h @@ -17,13 +17,8 @@ public: ~PhraseQueryNode() override; bool evaluate() const override; const HitList & evaluateHits(HitList & hl) const override; - void getPhrases(QueryNodeRefList & tl) override; - void getPhrases(ConstQueryNodeRefList & tl) const override; void unpack_match_data(uint32_t docid, const fef::ITermData& td, fef::MatchData& match_data) override; - void getLeaves(QueryTermList & tl) override; - void getLeaves(ConstQueryTermList & tl) const override; size_t width() const override; - MultiTerm* as_multi_term() noexcept override; }; } diff --git a/searchlib/src/vespa/searchlib/query/streaming/query.cpp b/searchlib/src/vespa/searchlib/query/streaming/query.cpp index f1b3a804c50..77424fb2d62 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/query.cpp +++ b/searchlib/src/vespa/searchlib/query/streaming/query.cpp @@ -63,22 +63,6 @@ QueryConnector::getLeaves(ConstQueryTermList & tl) const } } -void -QueryConnector::getPhrases(QueryNodeRefList & tl) -{ - for (const auto & node : _children) { - node->getPhrases(tl); - } -} - -void -QueryConnector::getPhrases(ConstQueryNodeRefList & tl) const -{ - for (const auto & node : _children) { - node->getPhrases(tl); - } -} - size_t QueryConnector::depth() const { @@ -218,20 +202,6 @@ Query::getLeaves(ConstQueryTermList & tl) const { } void -Query::getPhrases(QueryNodeRefList & tl) { - if (valid()) { - _root->getPhrases(tl); - } -} - -void -Query::getPhrases(ConstQueryNodeRefList & tl) const { - if (valid()) { - _root->getPhrases(tl); - } -} - -void Query::reset() { if (valid()) { _root->reset(); diff --git a/searchlib/src/vespa/searchlib/query/streaming/query.h b/searchlib/src/vespa/searchlib/query/streaming/query.h index 5296d3a4f69..e91a2f91dc5 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/query.h +++ b/searchlib/src/vespa/searchlib/query/streaming/query.h @@ -19,8 +19,6 @@ public: void reset() override; void getLeaves(QueryTermList & tl) override; void getLeaves(ConstQueryTermList & tl) const override; - void getPhrases(QueryNodeRefList & tl) override; - void getPhrases(ConstQueryNodeRefList & tl) const override; size_t depth() const override; size_t width() const override; virtual void visitMembers(vespalib::ObjectVisitor &visitor) const; @@ -139,9 +137,6 @@ public: /// Will get all leafnodes. void getLeaves(QueryTermList & tl); void getLeaves(ConstQueryTermList & tl) const; - /// Gives you all phrases of this tree. - void getPhrases(QueryNodeRefList & tl); - void getPhrases(ConstQueryNodeRefList & tl) const; bool evaluate() const; size_t depth() const; size_t width() const; diff --git a/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp b/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp index a0abdcd28fb..44df253a2fd 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp +++ b/searchlib/src/vespa/searchlib/query/streaming/querynode.cpp @@ -265,6 +265,8 @@ QueryNode::build_phrase_term(const QueryNodeResultFactory& factory, SimpleQueryS { auto phrase = std::make_unique<PhraseQueryNode>(factory.create(), queryRep.getIndexName(), queryRep.getArity()); auto arity = queryRep.getArity(); + phrase->setWeight(queryRep.GetWeight()); + phrase->setUniqueId(queryRep.getUniqueId()); for (size_t i = 0; i < arity; ++i) { queryRep.next(); auto qn = Build(phrase.get(), factory, queryRep, false); @@ -274,6 +276,10 @@ QueryNode::build_phrase_term(const QueryNodeResultFactory& factory, SimpleQueryS std::unique_ptr<QueryTerm> qt(qtp); phrase->add_term(std::move(qt)); } + if (!phrase->get_terms().empty()) { + auto& first = *phrase->get_terms().front(); + phrase->setIndex(first.getIndex()); + } return phrase; } diff --git a/searchlib/src/vespa/searchlib/query/streaming/querynode.h b/searchlib/src/vespa/searchlib/query/streaming/querynode.h index 01974c70843..4c7d9e88930 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/querynode.h +++ b/searchlib/src/vespa/searchlib/query/streaming/querynode.h @@ -50,10 +50,6 @@ class QueryNode virtual void getLeaves(QueryTermList & tl) = 0; /// Gives you all leafs of this tree. Indicating that they are all const. virtual void getLeaves(ConstQueryTermList & tl) const = 0; - /// Gives you all phrases of this tree. - virtual void getPhrases(QueryNodeRefList & tl) = 0; - /// Gives you all phrases of this tree. Indicating that they are all const. - virtual void getPhrases(ConstQueryNodeRefList & tl) const = 0; virtual void setIndex(const vespalib::string & index) = 0; virtual const vespalib::string & getIndex() const = 0; diff --git a/searchlib/src/vespa/searchlib/query/streaming/queryterm.cpp b/searchlib/src/vespa/searchlib/query/streaming/queryterm.cpp index dbaeaa5d895..f01f815e673 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/queryterm.cpp +++ b/searchlib/src/vespa/searchlib/query/streaming/queryterm.cpp @@ -86,8 +86,6 @@ QueryTerm::QueryTerm(std::unique_ptr<QueryNodeResultBase> org, stringref termS, } } -void QueryTerm::getPhrases(QueryNodeRefList & tl) { (void) tl; } -void QueryTerm::getPhrases(ConstQueryNodeRefList & tl) const { (void) tl; } void QueryTerm::getLeaves(QueryTermList & tl) { tl.push_back(this); } void QueryTerm::getLeaves(ConstQueryTermList & tl) const { tl.push_back(this); } bool QueryTerm::evaluate() const { return !_hitList.empty(); } diff --git a/searchlib/src/vespa/searchlib/query/streaming/queryterm.h b/searchlib/src/vespa/searchlib/query/streaming/queryterm.h index de043237cff..2eaecb86854 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/queryterm.h +++ b/searchlib/src/vespa/searchlib/query/streaming/queryterm.h @@ -75,10 +75,6 @@ public: void reset() override; void getLeaves(QueryTermList & tl) override; void getLeaves(ConstQueryTermList & tl) const override; - /// Gives you all phrases of this tree. - void getPhrases(QueryNodeRefList & tl) override; - /// Gives you all phrases of this tree. Indicating that they are all const. - void getPhrases(ConstQueryNodeRefList & tl) const override; uint32_t add(uint32_t field_id, uint32_t element_id, int32_t element_weight, uint32_t position); void set_element_length(uint32_t hitlist_idx, uint32_t element_length); diff --git a/streamingvisitors/src/tests/querywrapper/querywrapper_test.cpp b/streamingvisitors/src/tests/querywrapper/querywrapper_test.cpp index 70b863e540b..2a4b9e1f869 100644 --- a/streamingvisitors/src/tests/querywrapper/querywrapper_test.cpp +++ b/streamingvisitors/src/tests/querywrapper/querywrapper_test.cpp @@ -26,7 +26,6 @@ void QueryWrapperTest::testQueryWrapper() { QueryNodeResultFactory empty; - PhraseQueryNode * null = NULL; { QueryBuilder<SimpleQueryNodeTypes> builder; builder.addAnd(3); @@ -48,42 +47,16 @@ QueryWrapperTest::testQueryWrapper() QueryTermList terms; q.getLeaves(terms); - ASSERT_TRUE(tl.size() == 5 && terms.size() == 5); - for (size_t i = 0; i < 5; ++i) { - EXPECT_EQUAL(tl[i].getTerm(), terms[i]); + ASSERT_TRUE(tl.size() == 3 && terms.size() == 3); + for (size_t i = 0; i < 3; ++i) { + EXPECT_EQUAL(tl[i], terms[i]); std::cout << "t[" << i << "]:" << terms[i] << std::endl; + auto phrase = dynamic_cast<PhraseQueryNode*>(terms[i]); + EXPECT_EQUAL(i == 1, phrase != nullptr); + if (i == 1) { + EXPECT_EQUAL(3u, phrase->get_terms().size()); + } } - - QueryNodeRefList phrases; - q.getPhrases(phrases); - for (size_t i = 0; i < phrases.size(); ++i) { - std::cout << "p[" << i << "]:" << phrases[i] << std::endl; - } - EXPECT_EQUAL(phrases.size(), 1u); - ASSERT_TRUE(phrases.size() == 1); - EXPECT_EQUAL(tl[0].getParent(), null); - EXPECT_EQUAL(tl[1].getParent(), phrases[0]); - EXPECT_EQUAL(tl[2].getParent(), phrases[0]); - EXPECT_EQUAL(tl[3].getParent(), phrases[0]); - EXPECT_EQUAL(tl[4].getParent(), null); - - EXPECT_EQUAL(tl[0].getIndex(), 0u); - EXPECT_EQUAL(tl[1].getIndex(), 0u); - EXPECT_EQUAL(tl[2].getIndex(), 1u); - EXPECT_EQUAL(tl[3].getIndex(), 2u); - EXPECT_EQUAL(tl[4].getIndex(), 0u); - - EXPECT_TRUE(!tl[0].isFirstPhraseTerm()); - EXPECT_TRUE( tl[1].isFirstPhraseTerm()); - EXPECT_TRUE(!tl[2].isFirstPhraseTerm()); - EXPECT_TRUE(!tl[3].isFirstPhraseTerm()); - EXPECT_TRUE(!tl[4].isFirstPhraseTerm()); - - EXPECT_TRUE(!tl[0].isPhraseTerm()); - EXPECT_TRUE( tl[1].isPhraseTerm()); - EXPECT_TRUE( tl[2].isPhraseTerm()); - EXPECT_TRUE( tl[3].isPhraseTerm()); - EXPECT_TRUE(!tl[4].isPhraseTerm()); } } diff --git a/streamingvisitors/src/tests/rank_processor/rank_processor_test.cpp b/streamingvisitors/src/tests/rank_processor/rank_processor_test.cpp index 0abff37d622..a4a4b4e696f 100644 --- a/streamingvisitors/src/tests/rank_processor/rank_processor_test.cpp +++ b/streamingvisitors/src/tests/rank_processor/rank_processor_test.cpp @@ -67,7 +67,7 @@ RankProcessorTest::test_unpack_match_data_for_term_node(bool interleaved_feature build_query(builder); auto& term_list = _query_wrapper->getTermList(); EXPECT_EQ(1u, term_list.size()); - auto node = dynamic_cast<QueryTerm*>(term_list.front().getTerm()); + auto node = dynamic_cast<QueryTerm*>(term_list.front()); EXPECT_NE(nullptr, node); auto& qtd = static_cast<QueryTermData &>(node->getQueryItem()); auto& td = qtd.getTermData(); @@ -132,7 +132,7 @@ TEST_F(RankProcessorTest, unpack_match_data_for_nearest_neighbor_query_node) build_query(builder); auto& term_list = _query_wrapper->getTermList(); EXPECT_EQ(1u, term_list.size()); - auto node = dynamic_cast<NearestNeighborQueryNode*>(term_list.front().getTerm()); + auto node = dynamic_cast<NearestNeighborQueryNode*>(term_list.front()); EXPECT_NE(nullptr, node); MockRawScoreCalculator calc; node->set_raw_score_calc(&calc); diff --git a/streamingvisitors/src/vespa/searchvisitor/querywrapper.cpp b/streamingvisitors/src/vespa/searchvisitor/querywrapper.cpp index 78229f401ad..aa0699a6552 100644 --- a/streamingvisitors/src/vespa/searchvisitor/querywrapper.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/querywrapper.cpp @@ -6,42 +6,10 @@ using namespace search::streaming; namespace streaming { -QueryWrapper::PhraseList::PhraseList(Query & query) - : _phrases() +QueryWrapper::QueryWrapper(Query & query) + : _termList() { - QueryNodeRefList phrases; - query.getPhrases(phrases); - for (size_t i = 0; i < phrases.size(); ++i) { - _phrases.push_back(static_cast<PhraseQueryNode *>(phrases[i])); - } -} - -PhraseQueryNode * -QueryWrapper::PhraseList::findPhrase(QueryTerm * term, size_t & index) -{ - for (size_t i = 0; i < _phrases.size(); ++i) { - auto& terms = _phrases[i]->get_terms(); - for (size_t j = 0; j < terms.size(); ++j) { - if (terms[j].get() == term) { - index = j; - return _phrases[i]; - } - } - } - return nullptr; -} - -QueryWrapper::QueryWrapper(Query & query) : - _phraseList(query), - _termList() -{ - QueryTermList leaves; - query.getLeaves(leaves); - for (size_t i = 0; i < leaves.size(); ++i) { - size_t index = 0; - PhraseQueryNode * parent = _phraseList.findPhrase(leaves[i], index); - _termList.push_back(Term(leaves[i], parent, index)); - } + query.getLeaves(_termList); } QueryWrapper::~QueryWrapper() = default; diff --git a/streamingvisitors/src/vespa/searchvisitor/querywrapper.h b/streamingvisitors/src/vespa/searchvisitor/querywrapper.h index 420ff215833..6134bf27d71 100644 --- a/streamingvisitors/src/vespa/searchvisitor/querywrapper.h +++ b/streamingvisitors/src/vespa/searchvisitor/querywrapper.h @@ -14,46 +14,9 @@ namespace streaming { class QueryWrapper { public: - class PhraseList { - private: - std::vector<search::streaming::PhraseQueryNode *> _phrases; - - public: - PhraseList(search::streaming::Query & query); - search::streaming::PhraseQueryNode * findPhrase(search::streaming::QueryTerm * term, size_t & index); - }; - - class Term { - private: - search::streaming::QueryTerm * _term; - search::streaming::PhraseQueryNode * _parent; - size_t _index; - - public: - Term() : - _term(nullptr), - _parent(nullptr), - _index(0) - { - } - Term(search::streaming::QueryTerm * term, search::streaming::PhraseQueryNode * parent, size_t index) : - _term(term), - _parent(parent), - _index(index) - { - } - search::streaming::QueryTerm * getTerm() { return _term; } - search::streaming::PhraseQueryNode * getParent() { return _parent; } - size_t getIndex() const { return _index; } - bool isPhraseTerm() const { return _parent != nullptr; } - bool isFirstPhraseTerm() const { return isPhraseTerm() && getIndex() == 0; } - bool isGeoPosTerm() const { return (_term != nullptr) && _term->isGeoLoc(); } - }; - - using TermList = std::vector<Term>; + using TermList = search::streaming::QueryTermList; private: - PhraseList _phraseList; TermList _termList; public: diff --git a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp index bc78c24ba1b..3449df57513 100644 --- a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp @@ -61,46 +61,36 @@ RankProcessor::initQueryEnvironment() QueryWrapper::TermList & terms = _query.getTermList(); for (auto& term : terms) { - if (term.isGeoPosTerm()) { - const vespalib::string & fieldName = term.getTerm()->index(); - const vespalib::string & locStr = term.getTerm()->getTermString(); + if (term->isGeoLoc()) { + const vespalib::string & fieldName = term->index(); + const vespalib::string & locStr = term->getTermString(); _queryEnv.addGeoLocation(fieldName, locStr); } - if (!term.isPhraseTerm() || term.isFirstPhraseTerm()) { // register 1 term data per phrase - QueryTermData & qtd = dynamic_cast<QueryTermData &>(term.getTerm()->getQueryItem()); - - qtd.getTermData().setWeight(term.getTerm()->weight()); - qtd.getTermData().setUniqueId(term.getTerm()->uniqueId()); - if (term.isFirstPhraseTerm()) { - qtd.getTermData().setPhraseLength(term.getParent()->width()); - } else { - qtd.getTermData().setPhraseLength(1); - } - auto* nn_term = term.getTerm()->as_nearest_neighbor_query_node(); - if (nn_term != nullptr) { - qtd.getTermData().set_query_tensor_name(nn_term->get_query_tensor_name()); - } + QueryTermData & qtd = dynamic_cast<QueryTermData &>(term->getQueryItem()); + + qtd.getTermData().setWeight(term->weight()); + qtd.getTermData().setUniqueId(term->uniqueId()); + qtd.getTermData().setPhraseLength(term->width()); + auto* nn_term = term->as_nearest_neighbor_query_node(); + if (nn_term != nullptr) { + qtd.getTermData().set_query_tensor_name(nn_term->get_query_tensor_name()); + } - vespalib::string expandedIndexName = vsm::FieldSearchSpecMap::stripNonFields(term.getTerm()->index()); - const RankManager::View *view = _rankManagerSnapshot->getView(expandedIndexName); - if (view != nullptr) { - for (auto field_id : *view) { - qtd.getTermData().addField(field_id).setHandle(_mdLayout.allocTermField(field_id)); - } - } else { - LOG(warning, "Could not find a view for index '%s'. Ranking no fields.", - getIndexName(term.getTerm()->index(), expandedIndexName).c_str()); + vespalib::string expandedIndexName = vsm::FieldSearchSpecMap::stripNonFields(term->index()); + const RankManager::View *view = _rankManagerSnapshot->getView(expandedIndexName); + if (view != nullptr) { + for (auto field_id : *view) { + qtd.getTermData().addField(field_id).setHandle(_mdLayout.allocTermField(field_id)); } - - LOG(debug, "Setup query term '%s:%s' (%s)", - getIndexName(term.getTerm()->index(), expandedIndexName).c_str(), - term.getTerm()->getTerm(), - term.isFirstPhraseTerm() ? "phrase" : "term"); - _queryEnv.addTerm(&qtd.getTermData()); } else { - LOG(debug, "Ignore query term '%s:%s' (part of phrase)", - term.getTerm()->index().c_str(), term.getTerm()->getTerm()); + LOG(warning, "Could not find a view for index '%s'. Ranking no fields.", + getIndexName(term->index(), expandedIndexName).c_str()); } + + LOG(debug, "Setup query term '%s:%s'", + getIndexName(term->index(), expandedIndexName).c_str(), + term->getTerm()); + _queryEnv.addTerm(&qtd.getTermData()); } _rankSetup.prepareSharedState(_queryEnv, _queryEnv.getObjectStore()); _match_data = _mdLayout.createMatchData(); @@ -257,18 +247,10 @@ RankProcessor::unpackMatchData(uint32_t docId) void RankProcessor::unpack_match_data(uint32_t docid, MatchData &matchData, QueryWrapper& query) { - for (QueryWrapper::Term & term: query.getTermList()) { - if (!term.isPhraseTerm() || term.isFirstPhraseTerm()) { // consider 1 term data per phrase - bool isPhrase = term.isFirstPhraseTerm(); - QueryTermData & qtd = static_cast<QueryTermData &>(term.getTerm()->getQueryItem()); - const ITermData &td = qtd.getTermData(); - - if (isPhrase) { - term.getParent()->unpack_match_data(docid, td, matchData); - } else { - term.getTerm()->unpack_match_data(docid, td, matchData); - } - } + for (auto& term : query.getTermList()) { + QueryTermData & qtd = static_cast<QueryTermData &>(term->getQueryItem()); + const ITermData &td = qtd.getTermData(); + term->unpack_match_data(docid, td, matchData); } } |