diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-02-05 16:17:31 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2024-02-05 16:17:31 +0000 |
commit | c48eb091494ccb39d2edd0a1b50073f3c5dc4c2b (patch) | |
tree | 0a7221072c7c764914e67f1c81fbd635815f1405 /searchlib | |
parent | 19c39fc777a89ce8d9f3b71becfc93debab923ea (diff) |
Move Normalization from search::streaming => search
Diffstat (limited to 'searchlib')
5 files changed, 58 insertions, 28 deletions
diff --git a/searchlib/src/vespa/searchlib/query/CMakeLists.txt b/searchlib/src/vespa/searchlib/query/CMakeLists.txt index 29e9c02e6f2..1c47c910cb4 100644 --- a/searchlib/src/vespa/searchlib/query/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/query/CMakeLists.txt @@ -4,5 +4,6 @@ vespa_add_library(searchlib_query OBJECT query_term_simple.cpp query_term_ucs4.cpp query_term_decoder.cpp + query_normalization.cpp DEPENDS ) diff --git a/searchlib/src/vespa/searchlib/query/query_normalization.cpp b/searchlib/src/vespa/searchlib/query/query_normalization.cpp new file mode 100644 index 00000000000..e6a9d2202a9 --- /dev/null +++ b/searchlib/src/vespa/searchlib/query/query_normalization.cpp @@ -0,0 +1,31 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "query_normalization.h" +#include <ostream> + +namespace search { + +namespace { + +const char * +to_str(search::Normalizing norm) noexcept { + switch (norm) { + case search::Normalizing::NONE: + return "NONE"; + case search::Normalizing::LOWERCASE: + return "LOWERCASE"; + case search::Normalizing::LOWERCASE_AND_FOLD: + return "LOWERCASE_AND_FOLD"; + } + abort(); +} + +} + +std::ostream & +operator<<(std::ostream &os, Normalizing n) { + os << to_str(n); + return os; +} + +} diff --git a/searchlib/src/vespa/searchlib/query/query_normalization.h b/searchlib/src/vespa/searchlib/query/query_normalization.h new file mode 100644 index 00000000000..004876536b4 --- /dev/null +++ b/searchlib/src/vespa/searchlib/query/query_normalization.h @@ -0,0 +1,25 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include <vespa/vespalib/stllike/string.h> +#include <iosfwd> + +namespace search { + +enum class Normalizing { + NONE, + LOWERCASE, + LOWERCASE_AND_FOLD +}; + +std::ostream &operator<<(std::ostream &, Normalizing); + +class QueryNormalization { +public: + using Normalizing = search::Normalizing; + virtual ~QueryNormalization() = default; + virtual bool is_text_matching(vespalib::stringref index) const noexcept = 0; + virtual Normalizing normalizing_mode(vespalib::stringref index) const noexcept = 0; +}; + +} diff --git a/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.cpp b/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.cpp index af8ce7c9994..ccfd187441d 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.cpp +++ b/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.cpp @@ -4,22 +4,4 @@ namespace search::streaming { -namespace { - -const char* to_str(Normalizing norm) noexcept { - switch (norm) { - case Normalizing::NONE: return "NONE"; - case Normalizing::LOWERCASE: return "LOWERCASE"; - case Normalizing::LOWERCASE_AND_FOLD: return "LOWERCASE_AND_FOLD"; - } - abort(); -} - -} - -std::ostream& operator<<(std::ostream& os, Normalizing n) { - os << to_str(n); - return os; -} - } diff --git a/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.h b/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.h index 83fb27794a3..4097250f67e 100644 --- a/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.h +++ b/searchlib/src/vespa/searchlib/query/streaming/querynoderesultbase.h @@ -1,8 +1,7 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/vespalib/stllike/string.h> -#include <iosfwd> +#include <vespa/searchlib/query/query_normalization.h> #include <memory> namespace search::streaming { @@ -19,14 +18,6 @@ public: virtual QueryNodeResultBase * clone() const = 0; }; -enum class Normalizing { - NONE, - LOWERCASE, - LOWERCASE_AND_FOLD -}; - -std::ostream& operator<<(std::ostream&, Normalizing); - class QueryNodeResultFactory { public: virtual ~QueryNodeResultFactory() = default; |