Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Support join on bases of query match with `$foo(id: *)`.
Harpreet Sangar13b7d8ed71bb
diff --git a/src/filter.cpp b/src/filter.cppindex 10354ea0..6415500d 100644--- a/src/filter.cpp+++ b/src/filter.cpp@@ -418,7 +418,11 @@ Option<bool> toFilter(const std::string expression,filter_exp = {field_name, {}, {}};NUM_COMPARATOR id_comparator = EQUALS;size_t filter_value_index = 0;- if (raw_value[0] == '=') {+ if (raw_value == "*") { // Match all.+ // NOT_EQUALS comparator with no id match will get all the ids.+ id_comparator = NOT_EQUALS;+ filter_exp.apply_not_equals = true;+ } else if (raw_value[0] == '=') {id_comparator = EQUALS;while (++filter_value_index < raw_value.size() && raw_value[filter_value_index] == ' ');} else if (raw_value.size() >= 2 && raw_value[0] == '!' && raw_value[1] == '=') {diff --git a/src/filter_result_iterator.cpp b/src/filter_result_iterator.cppindex 7f4a45b9..3eff372e 100644--- a/src/filter_result_iterator.cpp+++ b/src/filter_result_iterator.cpp@@ -659,7 +659,8 @@ void filter_result_iterator_t::init() {values.push_back(std::to_string(result.docs[i]));}- filter filter_exp = {get_reference_field_op.get(), std::move(values), {EQUALS}};+ filter filter_exp = {get_reference_field_op.get(), std::move(values),+ std::vector<NUM_COMPARATOR>(result.count, EQUALS)};auto filter_tree_root = new filter_node_t(filter_exp);std::unique_ptr<filter_node_t> filter_tree_root_guard(filter_tree_root);diff --git a/test/collection_filtering_test.cpp b/test/collection_filtering_test.cppindex e82d083a..e572c32f 100644--- a/test/collection_filtering_test.cpp+++ b/test/collection_filtering_test.cpp@@ -1327,6 +1327,13 @@ TEST_F(CollectionFilteringTest, FilteringViaDocumentIds) {ASSERT_EQ(0, results["found"].get<size_t>());+ // match all IDs+ results = coll1->search("*",+ {}, "id: *",+ {}, sort_fields, {0}, 10, 1, FREQUENCY, {true}).get();++ ASSERT_EQ(4, results["found"].get<size_t>());+collectionManager.drop_collection("coll1");}diff --git a/test/collection_join_test.cpp b/test/collection_join_test.cppindex 495f9ba4..0494e2c6 100644--- a/test/collection_join_test.cpp+++ b/test/collection_join_test.cpp@@ -482,6 +482,21 @@ TEST_F(CollectionJoinTest, FilterByReference_SingleMatch) {ASSERT_EQ(1, res_obj["hits"].size());ASSERT_EQ("soap", result["hits"][0]["document"]["product_name"].get<std::string>());+ req_params = {+ {"collection", "Customers"},+ {"q", "Dan"},+ {"query_by", "customer_name"},+ {"filter_by", "$Products(id:*) && product_price:<100"},+ };++ search_op_bool = collectionManager.do_search(req_params, embedded_params, json_res, now_ts);+ ASSERT_TRUE(search_op_bool.ok());++ res_obj = nlohmann::json::parse(json_res);+ ASSERT_EQ(1, res_obj["found"].get<size_t>());+ ASSERT_EQ(1, res_obj["hits"].size());+ ASSERT_EQ("soap", result["hits"][0]["document"]["product_name"].get<std::string>());+collectionManager.drop_collection("Customers");collectionManager.drop_collection("Products");}