aboutsummaryrefslogtreecommitdiffstats
path: root/streamingvisitors/src/vespa/vsm/searcher/utf8flexiblestringfieldsearcher.cpp
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-05-15 00:41:35 +0200
committerGitHub <noreply@github.com>2022-05-15 00:41:35 +0200
commit4db8dcbf3395fd92b1348155142b85df5a754289 (patch)
tree912b02e614bc9889ea3543893cbeb699971e8156 /streamingvisitors/src/vespa/vsm/searcher/utf8flexiblestringfieldsearcher.cpp
parent287a799b270200aca440cad376272328128a5054 (diff)
Revert "Revert "Collapse vsm into streamingvisitors""
Diffstat (limited to 'streamingvisitors/src/vespa/vsm/searcher/utf8flexiblestringfieldsearcher.cpp')
-rw-r--r--streamingvisitors/src/vespa/vsm/searcher/utf8flexiblestringfieldsearcher.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/streamingvisitors/src/vespa/vsm/searcher/utf8flexiblestringfieldsearcher.cpp b/streamingvisitors/src/vespa/vsm/searcher/utf8flexiblestringfieldsearcher.cpp
new file mode 100644
index 00000000000..9aef99f9fa1
--- /dev/null
+++ b/streamingvisitors/src/vespa/vsm/searcher/utf8flexiblestringfieldsearcher.cpp
@@ -0,0 +1,69 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+#include "utf8flexiblestringfieldsearcher.h"
+
+#include <vespa/log/log.h>
+LOG_SETUP(".vsm.searcher.utf8flexiblestringfieldsearcher");
+
+using search::streaming::QueryTerm;
+using search::streaming::QueryTermList;
+
+namespace vsm {
+
+std::unique_ptr<FieldSearcher>
+UTF8FlexibleStringFieldSearcher::duplicate() const
+{
+ return std::make_unique<UTF8FlexibleStringFieldSearcher>(*this);
+}
+
+size_t
+UTF8FlexibleStringFieldSearcher::matchTerms(const FieldRef & f, const size_t mintsz)
+{
+ (void) mintsz;
+ size_t words = 0;
+ for (QueryTermList::iterator it = _qtl.begin(); it != _qtl.end(); ++it) {
+ words = matchTerm(f, **it);
+ }
+ return words;
+}
+
+size_t
+UTF8FlexibleStringFieldSearcher::matchTerm(const FieldRef & f, QueryTerm & qt)
+{
+ if (qt.isPrefix()) {
+ LOG(debug, "Use prefix match for prefix term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermRegular(f, qt);
+ } else if (qt.isSubstring()) {
+ LOG(debug, "Use substring match for substring term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermSubstring(f, qt);
+ } else if (qt.isSuffix()) {
+ LOG(debug, "Use suffix match for suffix term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermSuffix(f, qt);
+ } else if (qt.isExactstring()) {
+ LOG(debug, "Use exact match for exact term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermExact(f, qt);
+ } else {
+ if (substring()) {
+ LOG(debug, "Use substring match for term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermSubstring(f, qt);
+ } else if (suffix()) {
+ LOG(debug, "Use suffix match for term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermSuffix(f, qt);
+ } else if (exact()) {
+ LOG(debug, "Use exact match for term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermExact(f, qt);
+ } else {
+ LOG(debug, "Use regular/prefix match for term '%s:%s'", qt.index().c_str(), qt.getTerm());
+ return matchTermRegular(f, qt);
+ }
+ }
+}
+
+UTF8FlexibleStringFieldSearcher::UTF8FlexibleStringFieldSearcher() :
+ UTF8StringFieldSearcherBase()
+{ }
+
+UTF8FlexibleStringFieldSearcher::UTF8FlexibleStringFieldSearcher(FieldIdT fId) :
+ UTF8StringFieldSearcherBase(fId)
+{ }
+
+}