diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-02-05 20:15:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-05 20:15:17 +0100 |
commit | 651e52209fd7084258c9e610814909a374aaf77d (patch) | |
tree | ac5809d110d84bd7b988765aa8d017aafa49ef5b | |
parent | 6eef2f69956fedf3556bf320a54502a94e56a20a (diff) | |
parent | 7fff28b4a889f8a1d62f83bfae1f24b1dd2cfc30 (diff) |
Merge pull request #30183 from vespa-engine/toregge/add-unpack-match-data-member-function-to-search-streaming-nearest-neighbor-query-node
Add unpack_match_data member function to
3 files changed, 18 insertions, 18 deletions
diff --git a/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.cpp b/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.cpp index 1317d1c0651..07d16c7bddc 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.cpp +++ b/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.cpp @@ -1,6 +1,8 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "nearest_neighbor_query_node.h" +#include <vespa/searchlib/fef/itermdata.h> +#include <vespa/searchlib/fef/matchdata.h> #include <cassert> namespace search::streaming { @@ -49,4 +51,18 @@ NearestNeighborQueryNode::get_raw_score() const return std::nullopt; } +void +NearestNeighborQueryNode::unpack_match_data(uint32_t docid, const fef::ITermData& td, fef::MatchData& match_data) +{ + auto raw_score = get_raw_score(); + if (raw_score.has_value()) { + if (td.numFields() == 1u) { + auto& tfd = td.field(0u); + auto tmd = match_data.resolveTermField(tfd.getHandle()); + assert(tmd != nullptr); + tmd->setRawScore(docid, raw_score.value()); + } + } +} + } diff --git a/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.h b/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.h index c3eaad45031..277956e27a4 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.h +++ b/searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.h @@ -52,6 +52,7 @@ public: const std::optional<double>& get_distance() const { return _distance; } // This is used during unpacking, and also signals to the RawScoreCalculator that the entire document was a match. std::optional<double> get_raw_score() const; + void unpack_match_data(uint32_t docid, const fef::ITermData& td, fef::MatchData& match_data) override; }; } diff --git a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp index 09699f79427..bc78c24ba1b 100644 --- a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp @@ -258,24 +258,7 @@ void RankProcessor::unpack_match_data(uint32_t docid, MatchData &matchData, QueryWrapper& query) { for (QueryWrapper::Term & term: query.getTermList()) { - auto nn_node = term.getTerm()->as_nearest_neighbor_query_node(); - if (nn_node != nullptr) { - auto raw_score = nn_node->get_raw_score(); - if (raw_score.has_value()) { - auto& qtd = static_cast<QueryTermData &>(term.getTerm()->getQueryItem()); - auto& td = qtd.getTermData(); - if (td.numFields() == 1u) { - auto tfd = td.field(0u); - auto tmd = matchData.resolveTermField(tfd.getHandle()); - assert(tmd != nullptr); - tmd->setRawScore(docid, raw_score.value()); - } - } - } else if (auto multi_term = term.getTerm()->as_multi_term()) { - auto& qtd = static_cast<QueryTermData &>(term.getTerm()->getQueryItem()); - auto& td = qtd.getTermData(); - multi_term->unpack_match_data(docid, td, matchData); - } else if (!term.isPhraseTerm() || term.isFirstPhraseTerm()) { // consider 1 term data per phrase + 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(); |