Fix a bug in phrase search + filtering.

This commit is contained in:
Kishore Nallan 2022-01-12 19:41:33 +05:30
parent 609ac35c6d
commit 5b4b723672
2 changed files with 10 additions and 1 deletions

View File

@ -2206,6 +2206,10 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens,
}
}
if(!field_query_tokens[i].q_phrases.empty() && phrase_match_ids_size == 0) {
continue;
}
auto actual_filter_ids = filter_ids;
auto actual_filter_ids_length = filter_ids_length;
@ -2319,7 +2323,7 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens,
}
if(phrase_match_ids_size != 0) {
delete actual_filter_ids;
delete [] actual_filter_ids;
}
}

View File

@ -2241,6 +2241,11 @@ TEST_F(CollectionSpecificTest, PhraseSearchMultipleFields) {
ASSERT_EQ(1, results["hits"].size());
results = coll1->search(R"("dog and cat")", {"title", "description"},
"description: about", {}, {}, {2, 2}, 10, 1, FREQUENCY, {true, true}, 10).get();
ASSERT_EQ(1, results["hits"].size());
collectionManager.drop_collection("coll1");
}