diff options
author | Tor Egge <Tor.Egge@online.no> | 2024-02-05 14:51:10 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2024-02-05 14:51:10 +0100 |
commit | 7fff28b4a889f8a1d62f83bfae1f24b1dd2cfc30 (patch) | |
tree | b15fe487a9f0d91dad184412b102ac5037e8b71b /searchlib | |
parent | c57119796a4df33d9a7554508f5e85de5e934be7 (diff) |
Add unpack_match_data member function to
search::streaming::NearestNeighborQueryNode.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.cpp | 16 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/query/streaming/nearest_neighbor_query_node.h | 1 |
2 files changed, 17 insertions, 0 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; }; } |