summaryrefslogtreecommitdiffstats
path: root/streamingvisitors
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@vespa.ai>2024-01-16 13:16:29 +0000
committerTor Brede Vekterli <vekterli@vespa.ai>2024-01-16 13:23:32 +0000
commita71430109aa0310c1f97a0da68f8108cb6a101c4 (patch)
tree2e5638d8885f7a40d29622d1a3ecfa30344ab7d1 /streamingvisitors
parent324d3edb7de008da284af9b6e664298538dae0f4 (diff)
Propagate normalizing mode and max field length to new searcher
Needed to avoid default normalizing mode/max field length being used in the reconfigured searcher instance.
Diffstat (limited to 'streamingvisitors')
-rw-r--r--streamingvisitors/src/tests/searcher/searcher_test.cpp12
-rw-r--r--streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.cpp16
-rw-r--r--streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.h2
3 files changed, 25 insertions, 5 deletions
diff --git a/streamingvisitors/src/tests/searcher/searcher_test.cpp b/streamingvisitors/src/tests/searcher/searcher_test.cpp
index 791ed3ba787..24877866c1b 100644
--- a/streamingvisitors/src/tests/searcher/searcher_test.cpp
+++ b/streamingvisitors/src/tests/searcher/searcher_test.cpp
@@ -832,6 +832,18 @@ TEST("FieldSearchSpec construction") {
}
}
+TEST("FieldSearchSpec reconfiguration preserves match/normalization properties for new searcher") {
+ FieldSearchSpec f(7, "f0", Searchmethod::AUTOUTF8, Normalizing::NONE, "substring", 789);
+ QueryNodeResultFactory qnrf;
+ QueryTerm qt(qnrf.create(), "foo", "index", TermType::EXACTSTRINGTERM, Normalizing::LOWERCASE_AND_FOLD);
+ // Match type, normalization mode and max length are all properties of the original spec
+ // and should be propagated to the new searcher.
+ f.reconfig(qt);
+ EXPECT_EQUAL(f.searcher().match_type(), FieldSearcher::MatchType::SUBSTRING);
+ EXPECT_EQUAL(f.searcher().normalize_mode(), Normalizing::NONE);
+ EXPECT_EQUAL(f.searcher().maxFieldLength(), 789u);
+}
+
TEST("snippet modifier manager") {
FieldSearchSpecMapT specMap;
specMap[0] = FieldSearchSpec(0, "f0", Searchmethod::AUTOUTF8, Normalizing::LOWERCASE, "substring", 1000);
diff --git a/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.cpp b/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.cpp
index 468d8e0145a..9c8bb2f185a 100644
--- a/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.cpp
+++ b/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.cpp
@@ -114,9 +114,7 @@ FieldSearchSpec::FieldSearchSpec(const FieldIdT & fid, const vespalib::string &
break;
}
if (_searcher) {
- setMatchType(_searcher, _arg1);
- _searcher->maxFieldLength(maxLength());
- _searcher->normalize_mode(_normalize_mode);
+ propagate_settings_to_searcher();
}
}
@@ -138,8 +136,7 @@ FieldSearchSpec::reconfig(const QueryTerm & term)
term.isRegex())
{
_searcher = std::make_unique<UTF8FlexibleStringFieldSearcher>(id());
- // preserve the basic match property of the searcher
- setMatchType(_searcher, _arg1);
+ propagate_settings_to_searcher();
LOG(debug, "Reconfigured to use UTF8FlexibleStringFieldSearcher (%s) for field '%s' with id '%d'",
_searcher->prefix() ? "prefix" : "regular", name().c_str(), id());
_reconfigured = true;
@@ -150,6 +147,15 @@ FieldSearchSpec::reconfig(const QueryTerm & term)
}
}
+void
+FieldSearchSpec::propagate_settings_to_searcher()
+{
+ // preserve the basic match property and normalization mode of the searcher
+ setMatchType(_searcher, _arg1);
+ _searcher->maxFieldLength(maxLength());
+ _searcher->normalize_mode(_normalize_mode);
+}
+
vespalib::asciistream &
operator <<(vespalib::asciistream & os, const FieldSearchSpec & f)
{
diff --git a/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.h b/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.h
index 7ba9799991e..c862753a41c 100644
--- a/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.h
+++ b/streamingvisitors/src/vespa/vsm/vsm/fieldsearchspec.h
@@ -42,6 +42,8 @@ public:
friend vespalib::asciistream & operator <<(vespalib::asciistream & os, const FieldSearchSpec & f);
private:
+ void propagate_settings_to_searcher();
+
FieldIdT _id;
vespalib::string _name;
size_t _maxLength;