From 6d0a4fdb318b82faaa8eab42ab3620290459059e Mon Sep 17 00:00:00 2001 From: Xianhui Lin <35839735+JsDove@users.noreply.github.com> Date: Thu, 5 Dec 2024 10:18:40 +0800 Subject: [PATCH] fix: Fix bug for Search fails with filter expression contains underscore (#38085) Enhance the matching for elements within the UnaryRangeArray https://github.com/milvus-io/milvus/issues/38068 --------- Signed-off-by: Xianhui.Lin --- internal/core/src/exec/expression/UnaryExpr.cpp | 5 +++++ internal/core/src/exec/expression/UnaryExpr.h | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/internal/core/src/exec/expression/UnaryExpr.cpp b/internal/core/src/exec/expression/UnaryExpr.cpp index 748a0e993f28f..a6d27393e7e44 100644 --- a/internal/core/src/exec/expression/UnaryExpr.cpp +++ b/internal/core/src/exec/expression/UnaryExpr.cpp @@ -320,6 +320,11 @@ PhyUnaryRangeFilterExpr::ExecRangeVisitorImplArray() { func(data, valid_data, size, val, index, res, valid_res); break; } + case proto::plan::Match: { + UnaryElementFuncForArray func; + func(data, valid_data, size, val, index, res, valid_res); + break; + } default: PanicInfo( OpTypeInvalid, diff --git a/internal/core/src/exec/expression/UnaryExpr.h b/internal/core/src/exec/expression/UnaryExpr.h index 9dac7b0b6a1da..f9a0407a63245 100644 --- a/internal/core/src/exec/expression/UnaryExpr.h +++ b/internal/core/src/exec/expression/UnaryExpr.h @@ -191,6 +191,20 @@ struct UnaryElementFuncForArray { UnaryArrayCompare(array_data <= val); } else if constexpr (op == proto::plan::OpType::PrefixMatch) { UnaryArrayCompare(milvus::query::Match(array_data, val, op)); + } else if constexpr (op == proto::plan::OpType::Match) { + if constexpr (std::is_same_v) { + res[i] = false; + } else { + if (index >= src[i].length()) { + res[i] = false; + continue; + } + PatternMatchTranslator translator; + auto regex_pattern = translator(val); + RegexMatcher matcher(regex_pattern); + auto array_data = src[i].template get_data(index); + res[i] = matcher(array_data); + } } else { PanicInfo(OpTypeInvalid, "unsupported op_type:{} for "