[fix](invert index) fix error handling for match_regexp resulting in an empty match. (#29233)
This commit is contained in:
@ -70,10 +70,12 @@ void RegexpQuery::add(const std::wstring& field_name, const std::string& pattern
|
||||
}
|
||||
|
||||
if (is_match) {
|
||||
terms.emplace_back(std::move(input));
|
||||
if (++count >= _max_expansions) {
|
||||
if (_max_expansions > 0 && count >= _max_expansions) {
|
||||
break;
|
||||
}
|
||||
|
||||
terms.emplace_back(std::move(input));
|
||||
count++;
|
||||
}
|
||||
|
||||
_CLDECDELETE(term);
|
||||
@ -88,6 +90,10 @@ void RegexpQuery::add(const std::wstring& field_name, const std::string& pattern
|
||||
hs_free_database(database);
|
||||
})
|
||||
|
||||
if (terms.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
query.add(field_name, terms);
|
||||
}
|
||||
|
||||
|
||||
@ -14,3 +14,6 @@
|
||||
-- !sql --
|
||||
38
|
||||
|
||||
-- !sql --
|
||||
0
|
||||
|
||||
|
||||
@ -85,6 +85,8 @@ suite("test_index_match_regexp", "p0"){
|
||||
qt_sql """ select count() from test_index_match_regexp where request match_regexp 's\$'; """
|
||||
qt_sql """ select count() from test_index_match_regexp where request match_regexp 'er\$'; """
|
||||
qt_sql """ select count() from test_index_match_regexp where request match_regexp '.*tickets.*'; """
|
||||
qt_sql """ select count() from test_index_match_regexp where request match_regexp 'nonexistence'; """
|
||||
|
||||
} finally {
|
||||
//try_sql("DROP TABLE IF EXISTS ${testTable}")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user