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
Ignore explicit wildcard named field.
Kishore Nallanfa607f0013e4
diff --git a/src/collection.cpp b/src/collection.cppindex e8b3b8c1..45398fd7 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -2996,6 +2996,7 @@ Option<bool> Collection::detect_new_fields(nlohmann::json& document,bool parseable;bool found_dynamic_field = false;+ bool skip_field = false;// check against dynamic field definitionsfor(const auto& dynamic_field: dyn_fields) {@@ -3003,7 +3004,8 @@ Option<bool> Collection::detect_new_fields(nlohmann::json& document,// unless the field is auto or string*, ignore field name matching regexp patternif(kv.key() == dynamic_field.first && !dynamic_field.second.is_auto() &&!dynamic_field.second.is_string_star()) {- continue;+ skip_field = true;+ break;}new_field = dynamic_field.second;@@ -3013,6 +3015,11 @@ Option<bool> Collection::detect_new_fields(nlohmann::json& document,}}+ if(skip_field) {+ kv++;+ continue;+ }+if(!found_dynamic_field && fallback_field_type.empty()) {// we will not auto detect schema for non-dynamic fields if auto detection is not enabledkv++;@@ -3035,6 +3042,11 @@ Option<bool> Collection::detect_new_fields(nlohmann::json& document,const std::string& test_field_type = found_dynamic_field ? new_field.type : fallback_field_type;if(test_field_type == field_types::AUTO || field_types::is_string_or_array(test_field_type)) {+ if(kv.key() == ".*") {+ kv++;+ continue;+ }+parseable = field::get_type(kv.value(), field_type);if(!parseable) {diff --git a/test/collection_all_fields_test.cpp b/test/collection_all_fields_test.cppindex 80137d39..f3542b49 100644--- a/test/collection_all_fields_test.cpp+++ b/test/collection_all_fields_test.cpp@@ -1507,23 +1507,27 @@ TEST_F(CollectionAllFieldsTest, SchemaUpdateShouldBeAtomicForAllFields) {}TEST_F(CollectionAllFieldsTest, FieldNameMatchingRegexpShouldNotBeIndexed) {- std::vector<field> fields = {field("title", field_types::STRING, false),+ std::vector<field> fields = {field(".*", field_types::AUTO, false, true),+ field("title", field_types::STRING, false),field("name.*", field_types::STRING, true, true)};- Collection* coll1 = collectionManager.create_collection("coll1", 1, fields).get();+ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields, "", 0, field_types::AUTO).get();nlohmann::json doc1;doc1["id"] = "0";doc1["title"] = "One Two Three";doc1["name.*"] = "Rowling";+ doc1[".*"] = "foo";std::vector<std::string> json_lines;json_lines.push_back(doc1.dump());coll1->add_many(json_lines, doc1, UPSERT);+ json_lines[0] = doc1.dump();coll1->add_many(json_lines, doc1, UPSERT);ASSERT_EQ(1, coll1->_get_index()->_get_search_index().size());+ ASSERT_EQ(3, coll1->get_fields().size());auto results = coll1->search("one", {"title"},"", {}, {}, {2}, 10,