[fix](invert index) fix error handling for match_regexp resulting in an empty match. (#29233)

This commit is contained in:
zzzxl
2023-12-28 19:58:41 +08:00
committed by GitHub
parent a14daca7ba
commit c8a0d3e03c
3 changed files with 13 additions and 2 deletions

View File

@ -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);
}

View File

@ -14,3 +14,6 @@
-- !sql --
38
-- !sql --
0

View File

@ -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}")
}