This is an automated email from the ASF dual-hosted git repository.
airborne pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5c1c4f193f6 [fix](inverted index) multi_match supports any, all,
phrase. (#41663)
5c1c4f193f6 is described below
commit 5c1c4f193f62af583ebb32137611dc9cd425cc6b
Author: zzzxl <[email protected]>
AuthorDate: Wed Oct 16 13:56:41 2024 +0800
[fix](inverted index) multi_match supports any, all, phrase. (#41663)
1. Implemented multi_match query support for 'any', 'all', and 'phrase'
types as the second to last argument.
2. select * from tbl where multi_match(c1, c2, 'any | all | phrase |
phrase_prefix', 'x');
---
be/src/vec/functions/function_multi_match.cpp | 12 +-
.../inverted_index_p0/test_index_multi_match.out | 144 +++++++++++++++++++++
.../test_index_multi_match.groovy | 57 ++++++++
3 files changed, 210 insertions(+), 3 deletions(-)
diff --git a/be/src/vec/functions/function_multi_match.cpp
b/be/src/vec/functions/function_multi_match.cpp
index e2c8a4a4a83..02697dd4b0a 100644
--- a/be/src/vec/functions/function_multi_match.cpp
+++ b/be/src/vec/functions/function_multi_match.cpp
@@ -40,10 +40,17 @@ Status FunctionMultiMatch::execute_impl(FunctionContext*
/*context*/, Block& blo
}
InvertedIndexQueryType get_query_type(const std::string& query_type) {
- if (query_type == "phrase_prefix") {
+ if (query_type == "any") {
+ return InvertedIndexQueryType::MATCH_ANY_QUERY;
+ } else if (query_type == "all") {
+ return InvertedIndexQueryType::MATCH_ALL_QUERY;
+ } else if (query_type == "phrase") {
+ return InvertedIndexQueryType::MATCH_PHRASE_QUERY;
+ } else if (query_type == "phrase_prefix") {
return InvertedIndexQueryType::MATCH_PHRASE_PREFIX_QUERY;
+ } else {
+ return InvertedIndexQueryType::UNKNOWN_QUERY;
}
- return InvertedIndexQueryType::UNKNOWN_QUERY;
}
Status FunctionMultiMatch::evaluate_inverted_index(
@@ -62,7 +69,6 @@ Status FunctionMultiMatch::evaluate_inverted_index(
"parameter query type incorrect for function multi_match:
query_type = {}",
query_type);
}
-
// query
auto query_str = arguments[1].column->get_data_at(0);
auto param_type = arguments[1].type->get_type_as_type_descriptor().type;
diff --git a/regression-test/data/inverted_index_p0/test_index_multi_match.out
b/regression-test/data/inverted_index_p0/test_index_multi_match.out
index 77e3c86623e..86762cae36f 100644
--- a/regression-test/data/inverted_index_p0/test_index_multi_match.out
+++ b/regression-test/data/inverted_index_p0/test_index_multi_match.out
@@ -47,3 +47,147 @@
-- !sql --
44
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+30
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
+-- !sql --
+5
+
diff --git
a/regression-test/suites/inverted_index_p0/test_index_multi_match.groovy
b/regression-test/suites/inverted_index_p0/test_index_multi_match.groovy
index 884fbaffa62..75917b7e88a 100644
--- a/regression-test/suites/inverted_index_p0/test_index_multi_match.groovy
+++ b/regression-test/suites/inverted_index_p0/test_index_multi_match.groovy
@@ -123,6 +123,63 @@ suite("test_index_multi_match", "p0"){
qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'phrase_prefix', '2'); """
qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'phrase_prefix', 'a'); """
+ // match_any
+ qt_sql """ select count() from ${indexTbName1} where (clientip
match_any '2' or request match_any '2' or status match_any '2' or size
match_any '2'); """
+ qt_sql """ select count() from ${indexTbName2} where (clientip
match_any '2' or request match_any '2' or status match_any '2' or size
match_any '2'); """
+ qt_sql """ select count() from ${indexTbName3} where (clientip
match_any '2' or request match_any '2' or status match_any '2' or size
match_any '2'); """
+ qt_sql """ select count() from ${indexTbName4} where (clientip
match_any '2' or request match_any '2' or status match_any '2' or size
match_any '2'); """
+ qt_sql """ select count() from ${indexTbName1} where (clientip
match_any 'a' or request match_any 'a' or status match_any 'a' or size
match_any 'a'); """
+ qt_sql """ select count() from ${indexTbName2} where (clientip
match_any 'a' or request match_any 'a' or status match_any 'a' or size
match_any 'a'); """
+ qt_sql """ select count() from ${indexTbName3} where (clientip
match_any 'a' or request match_any 'a' or status match_any 'a' or size
match_any 'a'); """
+ qt_sql """ select count() from ${indexTbName4} where (clientip
match_any 'a' or request match_any 'a' or status match_any 'a' or size
match_any 'a'); """
+
+ qt_sql """ select count() from ${indexTbName1} where
multi_match(clientip, request, status, size, 'any', '2'); """
+ qt_sql """ select count() from ${indexTbName2} where
multi_match(clientip, request, status, size, 'any', '2'); """
+ qt_sql """ select count() from ${indexTbName3} where
multi_match(clientip, request, status, size, 'any', '2'); """
+ qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'any', '2'); """
+ qt_sql """ select count() from ${indexTbName1} where
multi_match(clientip, request, status, size, 'any', 'a'); """
+ qt_sql """ select count() from ${indexTbName2} where
multi_match(clientip, request, status, size, 'any', 'a'); """
+ qt_sql """ select count() from ${indexTbName3} where
multi_match(clientip, request, status, size, 'any', 'a'); """
+ qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'any', 'a'); """
+
+ // match_all
+ qt_sql """ select count() from ${indexTbName1} where (clientip
match_all '2' or request match_all '2' or status match_all '2' or size
match_all '2'); """
+ qt_sql """ select count() from ${indexTbName2} where (clientip
match_all '2' or request match_all '2' or status match_all '2' or size
match_all '2'); """
+ qt_sql """ select count() from ${indexTbName3} where (clientip
match_all '2' or request match_all '2' or status match_all '2' or size
match_all '2'); """
+ qt_sql """ select count() from ${indexTbName4} where (clientip
match_all '2' or request match_all '2' or status match_all '2' or size
match_all '2'); """
+ qt_sql """ select count() from ${indexTbName1} where (clientip
match_all 'a' or request match_all 'a' or status match_all 'a' or size
match_all 'a'); """
+ qt_sql """ select count() from ${indexTbName2} where (clientip
match_all 'a' or request match_all 'a' or status match_all 'a' or size
match_all 'a'); """
+ qt_sql """ select count() from ${indexTbName3} where (clientip
match_all 'a' or request match_all 'a' or status match_all 'a' or size
match_all 'a'); """
+ qt_sql """ select count() from ${indexTbName4} where (clientip
match_all 'a' or request match_all 'a' or status match_all 'a' or size
match_all 'a'); """
+
+ qt_sql """ select count() from ${indexTbName1} where
multi_match(clientip, request, status, size, 'all', '2'); """
+ qt_sql """ select count() from ${indexTbName2} where
multi_match(clientip, request, status, size, 'all', '2'); """
+ qt_sql """ select count() from ${indexTbName3} where
multi_match(clientip, request, status, size, 'all', '2'); """
+ qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'all', '2'); """
+ qt_sql """ select count() from ${indexTbName1} where
multi_match(clientip, request, status, size, 'all', 'a'); """
+ qt_sql """ select count() from ${indexTbName2} where
multi_match(clientip, request, status, size, 'all', 'a'); """
+ qt_sql """ select count() from ${indexTbName3} where
multi_match(clientip, request, status, size, 'all', 'a'); """
+ qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'all', 'a'); """
+
+ // match_phrase
+ qt_sql """ select count() from ${indexTbName1} where (clientip
match_phrase '2' or request match_phrase '2' or status match_phrase '2' or size
match_phrase '2'); """
+ qt_sql """ select count() from ${indexTbName2} where (clientip
match_phrase '2' or request match_phrase '2' or status match_phrase '2' or size
match_phrase '2'); """
+ qt_sql """ select count() from ${indexTbName3} where (clientip
match_phrase '2' or request match_phrase '2' or status match_phrase '2' or size
match_phrase '2'); """
+ qt_sql """ select count() from ${indexTbName4} where (clientip
match_phrase '2' or request match_phrase '2' or status match_phrase '2' or size
match_phrase '2'); """
+ qt_sql """ select count() from ${indexTbName1} where (clientip
match_phrase 'a' or request match_phrase 'a' or status match_phrase 'a' or size
match_phrase 'a'); """
+ qt_sql """ select count() from ${indexTbName2} where (clientip
match_phrase 'a' or request match_phrase 'a' or status match_phrase 'a' or size
match_phrase 'a'); """
+ qt_sql """ select count() from ${indexTbName3} where (clientip
match_phrase 'a' or request match_phrase 'a' or status match_phrase 'a' or size
match_phrase 'a'); """
+ qt_sql """ select count() from ${indexTbName4} where (clientip
match_phrase 'a' or request match_phrase 'a' or status match_phrase 'a' or size
match_phrase 'a'); """
+
+ qt_sql """ select count() from ${indexTbName1} where
multi_match(clientip, request, status, size, 'phrase', '2'); """
+ qt_sql """ select count() from ${indexTbName2} where
multi_match(clientip, request, status, size, 'phrase', '2'); """
+ qt_sql """ select count() from ${indexTbName3} where
multi_match(clientip, request, status, size, 'phrase', '2'); """
+ qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'phrase', '2'); """
+ qt_sql """ select count() from ${indexTbName1} where
multi_match(clientip, request, status, size, 'phrase', 'a'); """
+ qt_sql """ select count() from ${indexTbName2} where
multi_match(clientip, request, status, size, 'phrase', 'a'); """
+ qt_sql """ select count() from ${indexTbName3} where
multi_match(clientip, request, status, size, 'phrase', 'a'); """
+ qt_sql """ select count() from ${indexTbName4} where
multi_match(clientip, request, status, size, 'phrase', 'a'); """
+
} finally {
//try_sql("DROP TABLE IF EXISTS ${testTable}")
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]