From c48eb091494ccb39d2edd0a1b50073f3c5dc4c2b Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 5 Feb 2024 16:17:31 +0000 Subject: Move Normalization from search::streaming => search --- searchlib/src/vespa/searchlib/query/CMakeLists.txt | 1 + .../vespa/searchlib/query/query_normalization.cpp | 31 ++++++++++++++++++++++ .../vespa/searchlib/query/query_normalization.h | 25 +++++++++++++++++ .../query/streaming/querynoderesultbase.cpp | 18 ------------- .../query/streaming/querynoderesultbase.h | 11 +------- 5 files changed, 58 insertions(+), 28 deletions(-) create mode 100644 searchlib/src/vespa/searchlib/query/query_normalization.cpp create mode 100644 searchlib/src/vespa/searchlib/query/query_normalization.h (limited to 'searchlib') 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 + +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 +#include + +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 -#include +#include #include 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; -- cgit v1.2.3