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
Use of dynamic fields should activate coerce_or_reject.
kishorenc9c448793bdb1
diff --git a/include/field.h b/include/field.hindex 21173835..a000754e 100644--- a/include/field.h+++ b/include/field.h@@ -22,7 +22,7 @@ namespace field_types {static const std::string FLOAT_ARRAY = "float[]";static const std::string BOOL_ARRAY = "bool[]";- static bool is_string_or_array(const std::string type_def) {+ static bool is_string_or_array(const std::string& type_def) {return type_def == "string*";}}diff --git a/src/collection.cpp b/src/collection.cppindex d674783e..b12b6330 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -2457,7 +2457,8 @@ DIRTY_VALUES Collection::parse_dirty_values_option(std::string& dirty_values) coif(dirty_values_op.has_value()) {dirty_values_action = dirty_values_op.value();} else {- dirty_values_action = fallback_field_type.empty() ? DIRTY_VALUES::REJECT : DIRTY_VALUES::COERCE_OR_REJECT;+ dirty_values_action = (fallback_field_type.empty() && dynamic_fields.empty()) ?+ DIRTY_VALUES::REJECT : DIRTY_VALUES::COERCE_OR_REJECT;}return dirty_values_action;diff --git a/test/collection_all_fields_test.cpp b/test/collection_all_fields_test.cppindex 2e47d3e5..ff661bf8 100644--- a/test/collection_all_fields_test.cpp+++ b/test/collection_all_fields_test.cpp@@ -167,6 +167,23 @@ TEST_F(CollectionAllFieldsTest, IndexDocsWithoutSchema) {collectionManager.drop_collection("coll1");}+TEST_F(CollectionAllFieldsTest, CoerceDynamicStringField) {+ Collection *coll1;++ std::vector<field> fields = {field("title", field_types::STRING, true),+ field(".*_name", "string", true, true),};++ coll1 = collectionManager.get_collection("coll1").get();+ if (coll1 == nullptr) {+ coll1 = collectionManager.create_collection("coll1", 1, fields, "", 0, "").get();+ }++ std::string dirty_values;+ ASSERT_EQ(DIRTY_VALUES::COERCE_OR_REJECT, coll1->parse_dirty_values_option(dirty_values));++ collectionManager.drop_collection("coll1");+}+TEST_F(CollectionAllFieldsTest, HandleArrayTypes) {Collection *coll1;