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
Fix regression in partial update of record with embedding.
Kishore Nallanf33163ff164b
diff --git a/src/validator.cpp b/src/validator.cppindex f814c923..f8c23ee9 100644--- a/src/validator.cpp+++ b/src/validator.cpp@@ -716,7 +716,7 @@ Option<bool> validator_t::validate_embed_fields(const nlohmann::json& document,}}}- if(all_optional_and_null && !field.optional) {+ if(all_optional_and_null && !field.optional && !is_update) {return Option<bool>(400, "No valid fields found to create embedding for `" + field.name + "`, please provide at least one valid field or make the embedding field optional.");}}diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cppindex 2f55cd34..b55bb085 100644--- a/test/collection_vector_search_test.cpp+++ b/test/collection_vector_search_test.cpp@@ -1033,6 +1033,42 @@ TEST_F(CollectionVectorTest, EmbedFromOptionalNullField) {ASSERT_TRUE(add_op.ok());}+TEST_F(CollectionVectorTest, UpdateOfCollWithNonOptionalEmbeddingField) {+ nlohmann::json schema = R"({+ "name": "objects",+ "fields": [+ {"name": "name", "type": "string"},+ {"name": "about", "type": "string"},+ {"name": "embedding", "type":"float[]", "embed":{"from": ["name"], "model_config": {"model_name": "ts/e5-small"}}}+ ]+ })"_json;++ TextEmbedderManager::set_model_dir("/tmp/typesense_test/models");++ auto op = collectionManager.create_collection(schema);+ ASSERT_TRUE(op.ok());+ Collection* coll = op.get();++ nlohmann::json object;+ object["id"] = "0";+ object["name"] = "butter";+ object["about"] = "about butter";++ auto add_op = coll->add(object.dump(), CREATE);+ ASSERT_TRUE(add_op.ok());++ nlohmann::json update_object;+ update_object["id"] = "0";+ update_object["about"] = "something about butter";+ auto update_op = coll->add(update_object.dump(), EMPLACE);+ ASSERT_TRUE(update_op.ok());++ // action = update+ update_object["about"] = "something about butter 2";+ update_op = coll->add(update_object.dump(), UPDATE);+ ASSERT_TRUE(update_op.ok());+}+TEST_F(CollectionVectorTest, SkipEmbeddingOpWhenValueExists) {nlohmann::json schema = R"({"name": "objects",