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 search on non-indexed auto embedding fields
ozanarmagan273e67358e89
diff --git a/src/collection.cpp b/src/collection.cppindex 1bc16495..00fae63f 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -1308,6 +1308,11 @@ Option<nlohmann::json> Collection::search(std::string raw_query,return Option<nlohmann::json>(400, error);}+ if(!search_field.index) {+ std::string error = "Field `" + search_field.name + "` is marked as a non-indexed field in the schema.";+ return Option<nlohmann::json>(400, error);+ }+// if(TextEmbedderManager::model_dir.empty()) {// std::string error = "Text embedding is not enabled. Please set `model-dir` at startup.";// return Option<nlohmann::json>(400, error);diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cppindex b22686d1..42394323 100644--- a/test/collection_vector_search_test.cpp+++ b/test/collection_vector_search_test.cpp@@ -2648,4 +2648,48 @@ TEST_F(CollectionVectorTest, TestHybridSearchInvalidAlpha) {ASSERT_EQ("Malformed vector query string: ""`alpha` parameter must be a float between 0.0-1.0.", hybrid_results.error());+}++TEST_F(CollectionVectorTest, TestSearchNonIndexedEmbeddingField) {+ nlohmann::json schema = R"({+ "name": "test",+ "fields": [+ {+ "name": "name",+ "type": "string"+ },+ {+ "name": "embedding",+ "type": "float[]",+ "index": false,+ "optional": true,+ "embed": {+ "from": [+ "name"+ ],+ "model_config": {+ "model_name": "ts/e5-small"+ }+ }+ }+ ]+ })"_json;++ TextEmbedderManager::set_model_dir("/tmp/typesense_test/models");++ auto collection_create_op = collectionManager.create_collection(schema);+ ASSERT_TRUE(collection_create_op.ok());++ auto coll = collection_create_op.get();++ auto add_op = coll->add(R"({+ "name": "soccer"+ })"_json.dump());++ ASSERT_TRUE(add_op.ok());++ auto search_res = coll->search("soccer", {"name", "embedding"}, "", {}, {}, {0});+ ASSERT_FALSE(search_res.ok());++ ASSERT_EQ("Field `embedding` is marked as a non-indexed field in the schema.", search_res.error());}\ No newline at end of file