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

Fix index being updated with duplicate fields.

Kishore Nallana87b9e9a9ff8
diff --git a/src/collection.cpp b/src/collection.cpp
index 749e8ab0..e9acecd1 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -4399,7 +4399,17 @@ Option<bool> Collection::detect_new_fields(nlohmann::json& document,
}
}
- return field::flatten_doc(document, nested_fields, is_update, new_fields);
+ std::vector<field> flattened_fields;
+ auto flatten_op = field::flatten_doc(document, nested_fields, is_update, flattened_fields);
+ if(!flatten_op.ok()) {
+ return flatten_op;
+ }
+
+ for(const auto& flattened_field: flattened_fields) {
+ if(schema.find(flattened_field.name) == schema.end()) {
+ new_fields.push_back(flattened_field);
+ }
+ }
}
return Option<bool>(true);