From 5203511fa24da1609e2393a437caa088b147ee1c Mon Sep 17 00:00:00 2001 From: Arne Juul Date: Sat, 3 Feb 2024 12:02:27 +0000 Subject: wire feature overrides --- .../src/vespa/searchvisitor/rankprocessor.cpp | 6 ++++-- .../src/vespa/searchvisitor/rankprocessor.h | 4 +++- .../src/vespa/searchvisitor/searchvisitor.cpp | 20 +++++++++++++++----- .../src/vespa/searchvisitor/searchvisitor.h | 2 ++ 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp index 070563859a5..96e8ca89a04 100644 --- a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.cpp @@ -120,7 +120,7 @@ RankProcessor::initHitCollector(size_t wantedHitCount) void RankProcessor::setupRankProgram(RankProgram &program) { - program.setup(*_match_data, _queryEnv, search::fef::Properties()); + program.setup(*_match_data, _queryEnv, _featureOverrides); } void @@ -153,13 +153,15 @@ RankProcessor::RankProcessor(std::shared_ptr snapsh const vespalib::string &rankProfile, Query & query, const vespalib::string & location, - Properties & queryProperties, + const Properties & queryProperties, + const Properties & featureOverrides, const search::IAttributeManager * attrMgr) : _rankManagerSnapshot(std::move(snapshot)), _rankSetup(_rankManagerSnapshot->getRankSetup(rankProfile)), _query(query), _queryEnv(location, _rankManagerSnapshot->getIndexEnvironment(rankProfile), queryProperties, attrMgr), + _featureOverrides(featureOverrides), _mdLayout(), _match_data(), _rankProgram(), diff --git a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.h b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.h index 3001da086ec..5651917ce7a 100644 --- a/streamingvisitors/src/vespa/searchvisitor/rankprocessor.h +++ b/streamingvisitors/src/vespa/searchvisitor/rankprocessor.h @@ -31,6 +31,7 @@ private: QueryWrapper _query; QueryEnvironment _queryEnv; + const search::fef::Properties &_featureOverrides; search::fef::MatchDataLayout _mdLayout; search::fef::MatchData::UP _match_data; search::fef::RankProgram::UP _rankProgram; @@ -62,7 +63,8 @@ public: const vespalib::string &rankProfile, search::streaming::Query & query, const vespalib::string & location, - search::fef::Properties & queryProperties, + const search::fef::Properties & queryProperties, + const search::fef::Properties & featureOverrides, const search::IAttributeManager * attrMgr); void initForRanking(size_t wantedHitCount); diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp index 979e5f25b6a..a1e8fddc3bf 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp +++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.cpp @@ -431,9 +431,18 @@ SearchVisitor::init(const Parameters & params) LOG(debug, "Properties[%u]: name '%s', size '%u'", i, prop.getName(), prop.size()); if (strcmp(prop.getName(), "rank") == 0) { // pick up rank properties for (uint32_t j = 0; j < prop.size(); ++j) { - LOG(debug, "Properties[%u][%u]: key '%s' -> value '%s'", i, j, prop.getKey(j), prop.getValue(j)); - _rankController.getQueryProperties().add(vespalib::string(prop.getKey(j), prop.getKeyLen(j)), - vespalib::string(prop.getValue(j), prop.getValueLen(j))); + vespalib::string k{prop.getKey(j), prop.getKeyLen(j)}; + vespalib::string v{prop.getValue(j), prop.getValueLen(j)}; + LOG(debug, "Properties[%u][%u]: key '%s' -> value '%s'", i, j, k.c_str(), v.c_str()); + _rankController.getQueryProperties().add(k, v); + } + } + if (strcmp(prop.getName(), "feature") == 0) { // pick up feature overrides + for (uint32_t j = 0; j < prop.size(); ++j) { + vespalib::string k{prop.getKey(j), prop.getKeyLen(j)}; + vespalib::string v{prop.getValue(j), prop.getValueLen(j)}; + LOG(debug, "Feature override[%u][%u]: key '%s' -> value '%s'", i, j, k.c_str(), v.c_str()); + _rankController.getFeatureOverrides().add(k, v); } } } @@ -647,6 +656,7 @@ SearchVisitor::RankController::RankController() : _rankManagerSnapshot(nullptr), _rankSetup(nullptr), _queryProperties(), + _featureOverrides(), _hasRanking(false), _rankProcessor(), _dumpFeatures(false), @@ -664,13 +674,13 @@ SearchVisitor::RankController::setupRankProcessors(Query & query, std::vector & attributeFields) { _rankSetup = &_rankManagerSnapshot->getRankSetup(_rankProfile); - _rankProcessor = std::make_unique(_rankManagerSnapshot, _rankProfile, query, location, _queryProperties, &attrMan); + _rankProcessor = std::make_unique(_rankManagerSnapshot, _rankProfile, query, location, _queryProperties, _featureOverrides, &attrMan); _rankProcessor->initForRanking(wantedHitCount); // register attribute vectors needed for ranking processAccessedAttributes(_rankProcessor->get_real_query_env(), true, attrMan, attributeFields); if (_dumpFeatures) { - _dumpProcessor = std::make_unique(_rankManagerSnapshot, _rankProfile, query, location, _queryProperties, &attrMan); + _dumpProcessor = std::make_unique(_rankManagerSnapshot, _rankProfile, query, location, _queryProperties, _featureOverrides, &attrMan); LOG(debug, "Initialize dump processor"); _dumpProcessor->initForDumping(wantedHitCount); // register attribute vectors needed for dumping diff --git a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h index ce40b5ba742..98d0747baec 100644 --- a/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h +++ b/streamingvisitors/src/vespa/searchvisitor/searchvisitor.h @@ -129,6 +129,7 @@ private: std::shared_ptr _rankManagerSnapshot; const search::fef::RankSetup * _rankSetup; search::fef::Properties _queryProperties; + search::fef::Properties _featureOverrides; bool _hasRanking; RankProcessor::UP _rankProcessor; bool _dumpFeatures; @@ -151,6 +152,7 @@ private: const vespalib::string &getRankProfile() const { return _rankProfile; } void setRankManagerSnapshot(const std::shared_ptr& snapshot) { _rankManagerSnapshot = snapshot; } search::fef::Properties & getQueryProperties() { return _queryProperties; } + search::fef::Properties & getFeatureOverrides() { return _featureOverrides; } RankProcessor * getRankProcessor() { return _rankProcessor.get(); } void setDumpFeatures(bool dumpFeatures) { _dumpFeatures = dumpFeatures; } bool getDumpFeatures() const { return _dumpFeatures; } -- cgit v1.2.3