summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-04-20 09:23:06 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-04-20 09:23:06 +0000
commit3614453f7b558a9a662b08a8d86665f2ed8257ee (patch)
treed620e69c07902019489cfd70e791e3253019b693 /searchcore
parent66b6364237ff60e26f98a821da5b7baa5b9c6eaf (diff)
Report incorrect rank-profile
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/matchers.cpp34
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/matchview.cpp3
2 files changed, 25 insertions, 12 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/server/matchers.cpp b/searchcore/src/vespa/searchcore/proton/server/matchers.cpp
index 62ae7774daf..809f2e0a744 100644
--- a/searchcore/src/vespa/searchcore/proton/server/matchers.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/matchers.cpp
@@ -4,26 +4,31 @@
#include <vespa/searchcore/proton/matching/matcher.h>
#include <vespa/searchcore/proton/matching/ranking_expressions.h>
#include <vespa/searchcore/proton/matching/onnx_models.h>
+#include <vespa/vespalib/util/issue.h>
+#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
namespace proton {
using matching::RankingExpressions;
using matching::OnnxModels;
+using matching::Matcher;
+using matching::MatchingStats;
+using namespace vespalib::make_string_short;
Matchers::Matchers(const vespalib::Clock &clock,
matching::QueryLimiter &queryLimiter,
const matching::IConstantValueRepo &constantValueRepo)
: _rpmap(),
- _fallback(new matching::Matcher(search::index::Schema(), search::fef::Properties(),
- clock, queryLimiter, constantValueRepo, RankingExpressions(), OnnxModels(), -1)),
+ _fallback(std::make_shared<Matcher>(search::index::Schema(), search::fef::Properties(), clock, queryLimiter,
+ constantValueRepo, RankingExpressions(), OnnxModels(), -1)),
_default()
{ }
Matchers::~Matchers() = default;
void
-Matchers::add(const vespalib::string &name, std::shared_ptr<matching::Matcher> matcher)
+Matchers::add(const vespalib::string &name, std::shared_ptr<Matcher> matcher)
{
if ((name == "default") || ! _default) {
_default = matcher;
@@ -31,30 +36,37 @@ Matchers::add(const vespalib::string &name, std::shared_ptr<matching::Matcher> m
_rpmap[name] = std::move(matcher);
}
-matching::MatchingStats
+MatchingStats
Matchers::getStats() const
{
- matching::MatchingStats stats;
+ MatchingStats stats;
for (const auto & entry : _rpmap) {
stats.add(entry.second->getStats());
}
return stats;
}
-matching::MatchingStats
+MatchingStats
Matchers::getStats(const vespalib::string &name) const
{
auto it = _rpmap.find(name);
- return it != _rpmap.end() ? it->second->getStats() :
- matching::MatchingStats();
+ return it != _rpmap.end() ? it->second->getStats() : MatchingStats();
}
-matching::Matcher::SP
+std::shared_ptr<Matcher>
Matchers::lookup(const vespalib::string &name) const
{
Map::const_iterator found(_rpmap.find(name));
- return (found != _rpmap.end()) ? found->second : _default;
- //TODO add warning log message when not found, may want to use "_fallback" in most cases here
+ if (found == _rpmap.end()) {
+ if (_default) {
+ vespalib::Issue::report(fmt("Failed to find rank-profile '%s'. Falling back to 'default'", name.c_str()));
+ return _default;
+ } else {
+ vespalib::Issue::report(fmt("Failed to find rank-profile '%s'. Most likely a configuration issue.", name.c_str()));
+ return _fallback;
+ }
+ }
+ return found->second;
}
vespalib::string
diff --git a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp
index 210de685472..53cc3e27d6c 100644
--- a/searchcore/src/vespa/searchcore/proton/server/matchview.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/matchview.cpp
@@ -55,7 +55,8 @@ MatchView::getMatcher(const vespalib::string & rankProfile) const
Matcher::SP retval = _matchers->lookup(rankProfile);
if ( ! retval) {
throw IllegalArgumentException(fmt("Failed locating Matcher for rank profile '%s' docIdLimit=%d num_matchers=%d matchers='%s'",
- rankProfile.c_str(), _docIdLimit.get(), _matchers->numMatchers(), _matchers->listMatchers().c_str()), VESPA_STRLOC);
+ rankProfile.c_str(), _docIdLimit.get(), _matchers->numMatchers(), _matchers->listMatchers().c_str()),
+ VESPA_STRLOC);
}
LOG(debug, "Rankprofile = %s has termwise_limit=%f", rankProfile.c_str(), retval->get_termwise_limit());
return retval;