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
Add `reference_fields` map in `Collection`.
Harpreet Sangar39a027043431
diff --git a/include/index.h b/include/index.hindex fdc059d7..92b9f7af 100644--- a/include/index.h+++ b/include/index.h@@ -708,7 +708,7 @@ public:void do_reference_filtering_with_lock(std::pair<uint32_t, uint32_t*>& reference_index_ids,filter_node_t* filter_tree_root,- const std::string& reference_field_name) const;+ const std::string& reference_helper_field_name) const;void refresh_schemas(const std::vector<field>& new_fields, const std::vector<field>& del_fields);diff --git a/src/collection.cpp b/src/collection.cppindex 3a740723..c3ef5a49 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -2586,11 +2586,10 @@ Option<bool> Collection::get_reference_filter_ids(const std::string & filter_questd::shared_lock lock(mutex);std::string reference_field_name;- for (auto const& field: fields) {- if (!field.reference.empty() &&- field.reference.find(collection_name) == 0 &&- field.reference.find('.') == collection_name.size()) {- reference_field_name = field.name;+ for (auto const& pair: reference_fields) {+ auto reference_pair = pair.second;+ if (reference_pair.collection == collection_name) {+ reference_field_name = reference_pair.field;break;}}@@ -2608,7 +2607,8 @@ Option<bool> Collection::get_reference_filter_ids(const std::string & filter_quereturn filter_op;}- reference_field_name += "_sequence_id";+ // Reference helper field has the sequence id of other collection's documents.+ reference_field_name += REFERENCE_HELPER_FIELD_SUFFIX;index->do_reference_filtering_with_lock(reference_index_ids, filter_tree_root, reference_field_name);delete filter_tree_root;diff --git a/test/collection_join_test.cpp b/test/collection_join_test.cppindex 9db121aa..b25439e6 100644--- a/test/collection_join_test.cpp+++ b/test/collection_join_test.cpp@@ -265,6 +265,7 @@ TEST_F(CollectionJoinTest, IndexDocumentHavingReferenceField) {}ASSERT_TRUE(add_op.ok());}+collectionManager.drop_collection("Customers");customers_schema_json =R"({@@ -708,4 +709,4 @@ TEST_F(CollectionJoinTest, IncludeFieldsByReference_SingleMatch) {// // 3 fields in Products document and 2 fields from Customers document// ASSERT_EQ(5, res_obj["hits"][0]["document"].size());// ASSERT_EQ(1, res_obj["hits"][0]["document"].count("product_id_sequence_id"));-}\ No newline at end of file+}