This is an automated email from the ASF dual-hosted git repository. jianliangqi 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 6adb3fdf11 [fix](match_phrase) Fix the inconsistent query result for 'match_phrase' after creating index without support_phrase property (#20258) 6adb3fdf11 is described below commit 6adb3fdf11fedef90f649a90a892e4787bc671c3 Author: YueW <45946325+tany...@users.noreply.github.com> AuthorDate: Wed May 31 18:09:50 2023 +0800 [fix](match_phrase) Fix the inconsistent query result for 'match_phrase' after creating index without support_phrase property (#20258) if create inverted index without support_phrase property, remaining the match_phrase condition to filter by match function. --- be/src/common/status.h | 2 + be/src/olap/match_predicate.cpp | 15 +++ be/src/olap/match_predicate.h | 1 + .../rowset/segment_v2/inverted_index_reader.cpp | 4 + .../olap/rowset/segment_v2/inverted_index_reader.h | 5 + be/src/olap/rowset/segment_v2/segment_iterator.cpp | 1 + be/src/vec/functions/match.cpp | 17 ++- .../inverted_index_p0/test_index_match_phrase.out | 129 ++++++++++++++++++ ...rase_select.out => test_index_match_select.out} | 0 ...elect.groovy => test_index_match_phrase.groovy} | 145 ++++++++------------- ...elect.groovy => test_index_match_select.groovy} | 4 +- 11 files changed, 231 insertions(+), 92 deletions(-) diff --git a/be/src/common/status.h b/be/src/common/status.h index 5b3acfae10..ba634df13c 100644 --- a/be/src/common/status.h +++ b/be/src/common/status.h @@ -265,6 +265,7 @@ E(INVERTED_INDEX_FILE_NOT_FOUND, -6003); E(INVERTED_INDEX_FILE_HIT_LIMIT, -6004); E(INVERTED_INDEX_NO_TERMS, -6005); E(INVERTED_INDEX_RENAME_FILE_FAILED, -6006); +E(INVERTED_INDEX_EVALUATE_SKIPPED, -6007); #undef E } // namespace ErrorCode @@ -294,6 +295,7 @@ constexpr bool capture_stacktrace() { && code != ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND && code != ErrorCode::INVERTED_INDEX_FILE_HIT_LIMIT && code != ErrorCode::INVERTED_INDEX_NO_TERMS + && code != ErrorCode::INVERTED_INDEX_EVALUATE_SKIPPED && code != ErrorCode::META_KEY_NOT_FOUND && code != ErrorCode::PUSH_VERSION_ALREADY_EXIST && code != ErrorCode::TRANSACTION_NOT_EXIST diff --git a/be/src/olap/match_predicate.cpp b/be/src/olap/match_predicate.cpp index 9a1a782db5..b5b4882713 100644 --- a/be/src/olap/match_predicate.cpp +++ b/be/src/olap/match_predicate.cpp @@ -21,6 +21,7 @@ #include "exec/olap_utils.h" #include "olap/field.h" +#include "olap/inverted_index_parser.h" #include "olap/olap_common.h" #include "olap/rowset/segment_v2/inverted_index_cache.h" #include "olap/rowset/segment_v2/inverted_index_reader.h" @@ -43,6 +44,10 @@ Status MatchPredicate::evaluate(const Schema& schema, InvertedIndexIterator* ite if (iterator == nullptr) { return Status::OK(); } + if (_skip_evaluate(iterator)) { + LOG(INFO) << "match predicate evaluate skipped."; + return Status::Error<ErrorCode::INVERTED_INDEX_EVALUATE_SKIPPED>(); + } auto column_desc = schema.column(_column_id); roaring::Roaring roaring; auto inverted_index_query_type = _to_inverted_index_query_type(_match_type); @@ -111,4 +116,14 @@ InvertedIndexQueryType MatchPredicate::_to_inverted_index_query_type(MatchType m return ret; } +bool MatchPredicate::_skip_evaluate(InvertedIndexIterator* iterator) const { + if (_match_type == MatchType::MATCH_PHRASE && + iterator->get_inverted_index_reader_type() == InvertedIndexReaderType::FULLTEXT && + get_parser_phrase_support_string_from_properties(iterator->get_index_properties()) == + INVERTED_INDEX_PARSER_PHRASE_SUPPORT_NO) { + return true; + } + return false; +} + } // namespace doris \ No newline at end of file diff --git a/be/src/olap/match_predicate.h b/be/src/olap/match_predicate.h index ad793b90f8..e3e2ca45bd 100644 --- a/be/src/olap/match_predicate.h +++ b/be/src/olap/match_predicate.h @@ -64,6 +64,7 @@ private: std::string info = "MatchPredicate"; return info; } + bool _skip_evaluate(InvertedIndexIterator* iterator) const; private: std::string _value; diff --git a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp index 42f9a3362d..a97eae836f 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp +++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.cpp @@ -902,5 +902,9 @@ InvertedIndexReaderType InvertedIndexIterator::get_inverted_index_reader_type() return _reader->type(); } +const std::map<string, string>& InvertedIndexIterator::get_index_properties() const { + return _reader->get_index_properties(); +} + } // namespace segment_v2 } // namespace doris diff --git a/be/src/olap/rowset/segment_v2/inverted_index_reader.h b/be/src/olap/rowset/segment_v2/inverted_index_reader.h index 66cef27154..d68939fd5c 100644 --- a/be/src/olap/rowset/segment_v2/inverted_index_reader.h +++ b/be/src/olap/rowset/segment_v2/inverted_index_reader.h @@ -99,6 +99,10 @@ public: uint32_t get_index_id() const { return _index_meta.index_id(); } + const std::map<string, string>& get_index_properties() const { + return _index_meta.properties(); + } + static std::vector<std::wstring> get_analyse_result(const std::string& field_name, const std::string& value, InvertedIndexQueryType query_type, @@ -236,6 +240,7 @@ public: } InvertedIndexReaderType get_inverted_index_reader_type() const; + const std::map<string, string>& get_index_properties() const; private: OlapReaderStatistics* _stats; diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index a8755296dd..156b76641a 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -805,6 +805,7 @@ Status SegmentIterator::_apply_inverted_index_on_column_predicate( if (!res.ok()) { if (res.code() == ErrorCode::INVERTED_INDEX_FILE_NOT_FOUND || res.code() == ErrorCode::INVERTED_INDEX_FILE_HIT_LIMIT || + res.code() == ErrorCode::INVERTED_INDEX_EVALUATE_SKIPPED || (res.code() == ErrorCode::INVERTED_INDEX_NO_TERMS && need_remaining_after_evaluate)) { // 1. INVERTED_INDEX_FILE_NOT_FOUND means index file has not been built, diff --git a/be/src/vec/functions/match.cpp b/be/src/vec/functions/match.cpp index b9511bb0b8..fe55bf9a5a 100644 --- a/be/src/vec/functions/match.cpp +++ b/be/src/vec/functions/match.cpp @@ -74,6 +74,11 @@ Status FunctionMatchAny::execute_match(const std::string& column_name, doris::segment_v2::InvertedIndexReader::get_analyse_result( column_name, match_query_str, doris::segment_v2::InvertedIndexQueryType::MATCH_ANY_QUERY, inverted_index_ctx); + if (query_tokens.empty()) { + LOG(WARNING) << "invalid input query_str: " << match_query_str + << ", please check your query sql"; + return Status::Error<ErrorCode::INVERTED_INDEX_NO_TERMS>(); + } for (int i = 0; i < input_rows_count; i++) { const auto& str_ref = datas->get_data_at(i); std::vector<std::wstring> data_tokens = @@ -109,7 +114,11 @@ Status FunctionMatchAll::execute_match(const std::string& column_name, doris::segment_v2::InvertedIndexReader::get_analyse_result( column_name, match_query_str, doris::segment_v2::InvertedIndexQueryType::MATCH_ALL_QUERY, inverted_index_ctx); - + if (query_tokens.empty()) { + LOG(WARNING) << "invalid input query_str: " << match_query_str + << ", please check your query sql"; + return Status::Error<ErrorCode::INVERTED_INDEX_NO_TERMS>(); + } for (int i = 0; i < input_rows_count; i++) { const auto& str_ref = datas->get_data_at(i); std::vector<std::wstring> data_tokens = @@ -152,7 +161,11 @@ Status FunctionMatchPhrase::execute_match(const std::string& column_name, column_name, match_query_str, doris::segment_v2::InvertedIndexQueryType::MATCH_PHRASE_QUERY, inverted_index_ctx); - + if (query_tokens.empty()) { + LOG(WARNING) << "invalid input query_str: " << match_query_str + << ", please check your query sql"; + return Status::Error<ErrorCode::INVERTED_INDEX_NO_TERMS>(); + } for (int i = 0; i < input_rows_count; i++) { const auto& str_ref = datas->get_data_at(i); std::vector<std::wstring> data_tokens = diff --git a/regression-test/data/inverted_index_p0/test_index_match_phrase.out b/regression-test/data/inverted_index_p0/test_index_match_phrase.out new file mode 100644 index 0000000000..87b225e24d --- /dev/null +++ b/regression-test/data/inverted_index_p0/test_index_match_phrase.out @@ -0,0 +1,129 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside + +-- !sql -- + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: + +-- !sql -- + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- + +-- !sql -- + +-- !sql -- +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: + +-- !sql -- + +-- !sql -- +li sisi grade 6 li ba li liuliu 11 2016-10-01T00:00 tall:150cm, weight: 40kg, hobbies: sing, dancing, running good at handiwork and beaty +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists + +-- !sql -- +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside + +-- !sql -- + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside + +-- !sql -- + +-- !sql -- +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside + +-- !sql -- + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: + +-- !sql -- + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- + +-- !sql -- +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- + +-- !sql -- + +-- !sql -- +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside +san zhang grade 5 10 2017-10-01T00:00 tall:100cm, weight: 30kg, hobbies: + +-- !sql -- + +-- !sql -- +li sisi grade 6 li ba li liuliu 11 2016-10-01T00:00 tall:150cm, weight: 40kg, hobbies: sing, dancing, running good at handiwork and beaty +zhang san grade 5 zhang yi chen san buy dancing book 10 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: sing, dancing Like cultural and recreational activities Class activists + +-- !sql -- +zhang san yi grade 5 zhang yi chen san buy 11 2017-10-01T00:00 tall:120cm, weight: 35kg, hobbies: reading book A quiet little boy learn makes me happy + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside + +-- !sql -- + +-- !sql -- +li si grade 4 li er wan jiu 9 2018-10-01T00:00 tall:100cm, weight: 30kg, hobbies: playing ball A naughty boy i just want go outside + +-- !sql -- + diff --git a/regression-test/data/inverted_index_p0/test_index_match_term_and_phrase_select.out b/regression-test/data/inverted_index_p0/test_index_match_select.out similarity index 100% rename from regression-test/data/inverted_index_p0/test_index_match_term_and_phrase_select.out rename to regression-test/data/inverted_index_p0/test_index_match_select.out diff --git a/regression-test/suites/inverted_index_p0/test_index_match_term_and_phrase_select.groovy b/regression-test/suites/inverted_index_p0/test_index_match_phrase.groovy similarity index 64% copy from regression-test/suites/inverted_index_p0/test_index_match_term_and_phrase_select.groovy copy to regression-test/suites/inverted_index_p0/test_index_match_phrase.groovy index 1d6ba2f751..10b28e59ca 100644 --- a/regression-test/suites/inverted_index_p0/test_index_match_term_and_phrase_select.groovy +++ b/regression-test/suites/inverted_index_p0/test_index_match_phrase.groovy @@ -16,8 +16,8 @@ // under the License. -suite("test_index_match_term_and_phrase_select", "inverted_index_select"){ - def indexTbName1 = "index_range_match_term_and_phrase_select" +suite("test_index_match_phrase_select", "inverted_index_select"){ + def indexTbName1 = "test_index_match_phrase_select" def varchar_colume1 = "name" def varchar_colume2 = "grade" def varchar_colume3 = "fatherName" @@ -111,8 +111,9 @@ suite("test_index_match_term_and_phrase_select", "inverted_index_select"){ for (int i = 0; i < 2; i++) { logger.info("select table with index times " + i) - // case 1 + // case1: match phrase with index but support_phrase=fasle if (i > 0) { + // case2: match phrase with index and support_phrase=true logger.info("it's " + i + " times select, not first select, drop all index before select again") sql """ ALTER TABLE ${indexTbName1} @@ -130,13 +131,13 @@ suite("test_index_match_term_and_phrase_select", "inverted_index_select"){ logger.info("it's " + i + " times select, readd all index before select again") sql """ ALTER TABLE ${indexTbName1} - add index ${varchar_colume1}_idx(`${varchar_colume1}`) USING INVERTED PROPERTIES("parser"="english") COMMENT '${varchar_colume1} index', - add index ${varchar_colume2}_idx(`${varchar_colume2}`) USING INVERTED PROPERTIES("parser"="none") COMMENT '${varchar_colume2} index', - add index ${varchar_colume3}_idx(`${varchar_colume3}`) USING INVERTED PROPERTIES("parser"="standard") COMMENT ' ${varchar_colume3} index', + add index ${varchar_colume1}_idx(`${varchar_colume1}`) USING INVERTED PROPERTIES("parser"="english", "support_phrase" = "true") COMMENT '${varchar_colume1} index', + add index ${varchar_colume2}_idx(`${varchar_colume2}`) USING INVERTED PROPERTIES("parser"="none", "support_phrase" = "true") COMMENT '${varchar_colume2} index', + add index ${varchar_colume3}_idx(`${varchar_colume3}`) USING INVERTED PROPERTIES("parser"="standard", "support_phrase" = "true") COMMENT ' ${varchar_colume3} index', add index ${int_colume1}_idx(`${int_colume1}`) USING INVERTED COMMENT '${int_colume1} index', - add index ${string_colume1}_idx(`${string_colume1}`) USING INVERTED PROPERTIES("parser"="english") COMMENT '${string_colume1} index', - add index ${char_colume1}_idx(`${char_colume1}`) USING INVERTED PROPERTIES("parser"="standard") COMMENT '${char_colume1} index', - add index ${text_colume1}_idx(`${text_colume1}`) USING INVERTED PROPERTIES("parser"="standard") COMMENT '${text_colume1} index'; + add index ${string_colume1}_idx(`${string_colume1}`) USING INVERTED PROPERTIES("parser"="english", "support_phrase" = "true") COMMENT '${string_colume1} index', + add index ${char_colume1}_idx(`${char_colume1}`) USING INVERTED PROPERTIES("parser"="standard", "support_phrase" = "true") COMMENT '${char_colume1} index', + add index ${text_colume1}_idx(`${text_colume1}`) USING INVERTED PROPERTIES("parser"="standard", "support_phrase" = "true") COMMENT '${text_colume1} index'; """ wait_for_latest_op_on_table_finish(indexTbName1, timeout) sql """ build index ${varchar_colume1}_idx on ${indexTbName1} """ @@ -155,112 +156,80 @@ suite("test_index_match_term_and_phrase_select", "inverted_index_select"){ wait_for_build_index_on_partition_finish(indexTbName1, timeout) } - // case1: match term - // case1.0 test match "" + // case1: test match_phrase "" try { - sql """ select * from ${indexTbName1} where ${varchar_colume1} match_any "" order by name; """ + sql """ select * from ${indexTbName1} where ${varchar_colume1} match_phrase "" order by name; """ } catch(Exception ex) { - logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_any, result: " + ex) + logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_phrase, result: " + ex) } try { - sql """ select * from ${indexTbName1} where ${varchar_colume2} match_any "" order by name; """ + sql """ select * from ${indexTbName1} where ${varchar_colume2} match_phrase "" order by name; """ } catch(Exception ex) { - logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_any, result: " + ex) + logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_phrase, result: " + ex) } try { - sql """ select * from ${indexTbName1} where ${varchar_colume3} match_any "" order by name; """ + sql """ select * from ${indexTbName1} where ${varchar_colume3} match_phrase "" order by name; """ } catch(Exception ex) { - logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_any, result: " + ex) + logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_phrase, result: " + ex) } try { - sql """ select * from ${indexTbName1} where ${string_colume1} match_any "" order by name; """ + sql """ select * from ${indexTbName1} where ${string_colume1} match_phrase "" order by name; """ } catch(Exception ex) { - logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_any, result: " + ex) + logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_phrase, result: " + ex) } try { - sql """ select * from ${indexTbName1} where ${char_colume1} match_any "" order by name; """ + sql """ select * from ${indexTbName1} where ${char_colume1} match_phrase "" order by name; """ } catch(Exception ex) { - logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_any, result: " + ex) + logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_phrase, result: " + ex) } try { - sql """ select * from ${indexTbName1} where ${text_colume1} match_any "" order by name; """ + sql """ select * from ${indexTbName1} where ${text_colume1} match_phrase "" order by name; """ } catch(Exception ex) { - logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_any, result: " + ex) + logger.info("select * from ${indexTbName1} where ${varchar_colume1} match_phrase, result: " + ex) } - // case1.0 test int colume cannot use match + // case2: test int colume cannot use match_phrase def colume_match_result = "fail" try { - drop_result = sql "select * from ${indexTbName1} where ${int_colume1} match_any 9" + drop_result = sql "select * from ${indexTbName1} where ${int_colume1} match_phrase 9" colume_match_result = 'success' } catch(Exception ex) { logger.info("int colume should not match succ, result: " + ex) } assertEquals(colume_match_result, 'fail') - // case2: match same term with different way - // case2.0: test varchar default(simple) match same term with different way - qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_any 'zhang san' order by name; """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_all "zhang san" order by name; """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_all '"zhang san"' order by name; """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_any 'san' order by name; """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_any 'not exist name' order by name; """ - - // case2.1: test varchar none match same term with different way and repeate 5 times - for (int test_times = 0; test_times < 5; test_times++) { - qt_sql """ select * from ${indexTbName1} where ${varchar_colume2}='grade 5' order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume2}="grade 5" order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume2}='grade none' order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume2} match 'grade 5' order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume2} match "grade 5" order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume2} match 'grade none' order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume2} match 'grade' order by name """ - } - - // cas2.2 test varchar standard match same term with different way and repeate 5 times - for (test_times = 0; test_times < 5; test_times++) { - qt_sql """ select * from ${indexTbName1} where ${varchar_colume3} match_any 'zhang yi' order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume3} match_all "zhang yi" order by name """ - qt_sql """ select * from ${indexTbName1} where ${varchar_colume3} match_any '"zhang yi"' order by name """ - } - - // case3: test char standard match same term with different way and repeate 5 times - for (test_times = 0; test_times < 5; test_times++) { - qt_sql """ select * from ${indexTbName1} where ${char_colume1} match_any 'tall:100cm, weight: 30kg, hobbies:' order by name """ - qt_sql """ select * from ${indexTbName1} where ${char_colume1} match_all "tall:100cm, weight: 30kg, hobbies:" order by name """ - qt_sql """ select * from ${indexTbName1} where ${char_colume1} match_any '"tall:100cm, weight: 30kg, hobbies:"' order by name """ - } - - // case4: test string simple match same term with different way and repeate 5 times - for (test_times = 0; test_times < 5; test_times++) { - qt_sql """ select * from ${indexTbName1} where ${string_colume1} match_all 'A naughty boy' order by name """ - qt_sql """ select * from ${indexTbName1} where ${string_colume1} match_any "A naughty boy" order by name """ - qt_sql """ select * from ${indexTbName1} where ${string_colume1} match_any '"A naughty boy"' order by name """ - } - - // case5: test text standard match same term with different way and repeate 5 times - for (test_times = 0; test_times < 5; test_times++) { - qt_sql """ select * from ${indexTbName1} where ${text_colume1} match_all 'i just want go outside' order by name """ - qt_sql """ select * from ${indexTbName1} where ${text_colume1} match_any "i just want go outside" order by name """ - qt_sql """ select * from ${indexTbName1} where ${text_colume1} match_all '"i just want go outside"' order by name """ - } - - // case6: test term and phrase mix select - qt_sql """ - select * from ${indexTbName1} where - ${varchar_colume1} match_any 'zhang san' and - ${varchar_colume2} = 'grade 5' or - ${varchar_colume3} match_all "zhang yi" - order by name - """ - - qt_sql """ - select * from ${indexTbName1} where - ${char_colume1} match_all "tall:100cm, weight: 30kg, hobbies:" and - ${string_colume1} match_any "A naughty boy" or - ${text_colume1} match_all "i just want go outside" - order by name - """ + // case3: test match_phrase varchar column with english parser + qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_phrase 'zhang san' order by name; """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_phrase "li si" order by name; """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_phrase '"si li"' order by name; """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_phrase 'san zhang' order by name; """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume1} match_phrase 'not exist name' order by name; """ + + // case4: test match_phrase varchar column with none parser + qt_sql """ select * from ${indexTbName1} where ${varchar_colume2}='grade 5' order by name """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume2}="grade 5" order by name """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume2}='grade none' order by name """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume2} match_phrase 'grade 5' order by name """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume2} match_phrase 'grade none' order by name """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume2} match_phrase 'grade' order by name """ + + // cas5: test match_phrase varchar column with standard parser + qt_sql """ select * from ${indexTbName1} where ${varchar_colume3} match_phrase 'zhang yi' order by name """ + qt_sql """ select * from ${indexTbName1} where ${varchar_colume3} match_phrase "li liu" order by name """ + + // case6: test match_phrase char column with standard parser + qt_sql """ select * from ${indexTbName1} where ${char_colume1} match_phrase "tall:100cm" order by name """ + qt_sql """ select * from ${indexTbName1} where ${char_colume1} match_phrase "weight: hobbies:" order by name """ + qt_sql """ select * from ${indexTbName1} where ${char_colume1} match_phrase "hobbies: sing" order by name """ + + // case7: test match_phrase string column with english parser + qt_sql """ select * from ${indexTbName1} where ${string_colume1} match_phrase 'a quiet little boy' order by name """ + qt_sql """ select * from ${indexTbName1} where ${string_colume1} match_phrase "A naughty boy" order by name """ + qt_sql """ select * from ${indexTbName1} where ${string_colume1} match_phrase 'a boy' order by name """ + + // case8: test match_phrase text column with standard parser + qt_sql """ select * from ${indexTbName1} where ${text_colume1} match_phrase 'i just want go outside' order by name """ + qt_sql """ select * from ${indexTbName1} where ${text_colume1} match_phrase "good" order by name """ } diff --git a/regression-test/suites/inverted_index_p0/test_index_match_term_and_phrase_select.groovy b/regression-test/suites/inverted_index_p0/test_index_match_select.groovy similarity index 99% rename from regression-test/suites/inverted_index_p0/test_index_match_term_and_phrase_select.groovy rename to regression-test/suites/inverted_index_p0/test_index_match_select.groovy index 1d6ba2f751..4442c93c83 100644 --- a/regression-test/suites/inverted_index_p0/test_index_match_term_and_phrase_select.groovy +++ b/regression-test/suites/inverted_index_p0/test_index_match_select.groovy @@ -16,8 +16,8 @@ // under the License. -suite("test_index_match_term_and_phrase_select", "inverted_index_select"){ - def indexTbName1 = "index_range_match_term_and_phrase_select" +suite("test_index_match_select", "inverted_index_select"){ + def indexTbName1 = "test_index_match_select" def varchar_colume1 = "name" def varchar_colume2 = "grade" def varchar_colume3 = "fatherName" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org