Skip to content

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

Index `foo_sequence_id` field that stores sequence_id of referenced document.

Harpreet Sangar249294a657fe
diff --git a/src/field.cpp b/src/field.cpp
index 814c3c54..d29e909a 100644
--- a/src/field.cpp
+++ b/src/field.cpp
@@ -697,6 +697,13 @@ Option<bool> field::json_field_to_field(bool enable_nested_fields, nlohmann::jso
field_json[fields::reference])
);
+ if (!field_json[fields::reference].get<std::string>().empty()) {
+ the_fields.emplace_back(
+ field(field_json[fields::name].get<std::string>() + "_sequence_id", "string", false,
+ false, true)
+ );
+ }
+
return Option<bool>(true);
}
diff --git a/test/collection_join_test.cpp b/test/collection_join_test.cpp
index 0065e8ae..81a311bb 100644
--- a/test/collection_join_test.cpp
+++ b/test/collection_join_test.cpp
@@ -92,5 +92,10 @@ TEST_F(CollectionJoinTest, SchemaReferenceField) {
ASSERT_EQ(schema.at("customer_name").reference, "");
ASSERT_EQ(schema.at("product_id").reference, "Products.product_id");
+ ASSERT_EQ(schema.count("product_id_sequence_id"), 1);
+
+ auto field = schema.at("product_id_sequence_id");
+ ASSERT_TRUE(field.index);
+
collectionManager.drop_collection("Customers");
}
\ No newline at end of file