aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src
diff options
context:
space:
mode:
authorGeir Storli <geirst@yahooinc.com>2023-09-26 15:57:56 +0000
committerGeir Storli <geirst@yahooinc.com>2023-09-26 15:57:56 +0000
commitc305fed47692b01ba7398056b8d0514cab18bf39 (patch)
treebdeb1d8dcae91891ac81587622bf8cb165e660a2 /searchlib/src
parenta3f1ddde551d7c3092bcbdfb745e4e178da9be0f (diff)
Make DFA table algorithm selectable at query time.
Diffstat (limited to 'searchlib/src')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp b/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp
index aec317926f1..82709997228 100644
--- a/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/string_search_helper.cpp
@@ -11,6 +11,28 @@
namespace search::attribute {
+using FMA = vespalib::FuzzyMatchingAlgorithm;
+using LDT = vespalib::fuzzy::LevenshteinDfa::DfaType;
+
+namespace {
+
+LDT
+to_dfa_type(FMA algorithm)
+{
+ switch (algorithm) {
+ case FMA::DfaImplicit:
+ return LDT::Implicit;
+ case FMA::DfaExplicit:
+ return LDT::Explicit;
+ case FMA::DfaTable:
+ return LDT::Table;
+ default:
+ return LDT::Implicit;
+ }
+}
+
+}
+
StringSearchHelper::StringSearchHelper(QueryTermUCS4 & term, bool cased, vespalib::FuzzyMatchingAlgorithm fuzzy_matching_algorithm)
: _regex(),
_fuzzyMatcher(),
@@ -31,15 +53,13 @@ StringSearchHelper::StringSearchHelper(QueryTermUCS4 & term, bool cased, vespali
term.getFuzzyMaxEditDistance(),
term.getFuzzyPrefixLength(),
isCased());
- using FMA = vespalib::FuzzyMatchingAlgorithm;
- using LDT = vespalib::fuzzy::LevenshteinDfa::DfaType;
if ((fuzzy_matching_algorithm != FMA::BruteForce) &&
(term.getFuzzyMaxEditDistance() <= 2)) {
_dfa_fuzzy_matcher = std::make_unique<DfaFuzzyMatcher>(term.getTerm(),
term.getFuzzyMaxEditDistance(),
term.getFuzzyPrefixLength(),
isCased(),
- (fuzzy_matching_algorithm == FMA::DfaImplicit) ? LDT::Implicit : LDT::Explicit);
+ to_dfa_type(fuzzy_matching_algorithm));
}
} else if (isCased()) {
_term = term.getTerm();