Fix Index::get_filter_matches.

This commit is contained in:
Harpreet Sangar 2023-01-30 10:31:29 +05:30 committed by ozanarmagan
parent a3d79062ad
commit 3b2f42e1bc
2 changed files with 13 additions and 15 deletions

View File

@ -2024,9 +2024,6 @@ void Index::get_filter_matches(filter_node_t* const root, std::vector<std::pair<
return;
}
get_filter_matches(root->left, vec);
get_filter_matches(root->right, vec);
if (root->isOperator && root->filter_operator == OR) {
uint32_t* l_filter_ids = nullptr;
uint32_t l_filter_ids_length = 0;
@ -2052,7 +2049,8 @@ void Index::get_filter_matches(filter_node_t* const root, std::vector<std::pair<
do_filtering(root);
vec.emplace_back(root->match_index_ids.first, root);
} else {
// malformed
get_filter_matches(root->left, vec);
get_filter_matches(root->right, vec);
}
}

View File

@ -2590,17 +2590,17 @@ TEST_F(CollectionFilteringTest, ComplexFilterQuery) {
ASSERT_STREQ(id.c_str(), result_id.c_str());
}
// results = coll->search("Jeremy", {"name"}, "years:>2000 && ((age:<30 && rating:>5) || (age:>50 && rating:<5))",
// {}, sort_fields_desc, {0}, 10, 1, FREQUENCY, {false}).get();
// ASSERT_EQ(1, results["hits"].size());
//
// ids = {"2"};
// for (size_t i = 0; i < results["hits"].size(); i++) {
// nlohmann::json result = results["hits"].at(i);
// std::string result_id = result["document"]["id"];
// std::string id = ids.at(i);
// ASSERT_STREQ(id.c_str(), result_id.c_str());
// }
results = coll->search("Jeremy", {"name"}, "years:>2000 && ((age:<30 && rating:>5) || (age:>50 && rating:<5))",
{}, sort_fields_desc, {0}, 10, 1, FREQUENCY, {false}).get();
ASSERT_EQ(1, results["hits"].size());
ids = {"2"};
for (size_t i = 0; i < results["hits"].size(); i++) {
nlohmann::json result = results["hits"].at(i);
std::string result_id = result["document"]["id"];
std::string id = ids.at(i);
ASSERT_STREQ(id.c_str(), result_id.c_str());
}
collectionManager.drop_collection("ComplexFilterQueryCollection");
}