Skip to content

Commit

Permalink
[fix](inverted index) Corrected the issue of no_index_match failure c…
Browse files Browse the repository at this point in the history
…aused by empty data. (#37947)

1. Empty data caused no_index match_phrase_prefix to fail.
  • Loading branch information
zzzxl1993 authored and dataroaring committed Jul 17, 2024
1 parent 4aa31d5 commit fb001e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion be/src/vec/functions/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,12 @@ Status FunctionMatchPhrasePrefix::execute_match(
auto data_tokens = analyse_data_token(column_name, inverted_index_ctx, string_col, i,
array_offsets, current_src_array_offset);

for (size_t j = 0; j < data_tokens.size() - query_tokens.size() + 1; j++) {
int32_t dis_count = data_tokens.size() - query_tokens.size();
if (dis_count < 0) {
continue;
}

for (size_t j = 0; j < dis_count + 1; j++) {
if (data_tokens[j] == query_tokens[0] || query_tokens.size() == 1) {
bool match = true;
for (size_t k = 0; k < query_tokens.size(); k++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@
-- !sql --
66

-- !sql --
0

-- !sql --
0

Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ suite("test_no_index_match", "p0") {
create_httplogs_unique_table.call(testTable_unique)
load_httplogs_data.call(testTable_unique, 'httplogs_unique', 'true', 'json', 'documents-1000.json')

sql """ INSERT INTO ${testTable_unique} VALUES (1, '1', '', 1, 1); """

sql 'sync'

try {
Expand All @@ -89,6 +91,9 @@ suite("test_no_index_match", "p0") {
qt_sql """ select count() from ${testTable_unique} where (request match_phrase 'hm bg'); """
qt_sql """ select count() from ${testTable_unique} where (request match_phrase_prefix 'hm b'); """
qt_sql """ select count() from ${testTable_unique} where (request match_regexp 'la'); """

qt_sql """ select count() from ${testTable_unique} where (request match_phrase '欧冶工业品'); """
qt_sql """ select count() from ${testTable_unique} where (request match_phrase_prefix '欧冶工业品'); """
} finally {
}
} finally {
Expand Down

0 comments on commit fb001e2

Please sign in to comment.