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

Add test for vector field

ozanarmagandfa2872bdf50
diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cpp
index 42394323..04cd0096 100644
--- a/test/collection_vector_search_test.cpp
+++ b/test/collection_vector_search_test.cpp
@@ -2692,4 +2692,41 @@ TEST_F(CollectionVectorTest, TestSearchNonIndexedEmbeddingField) {
ASSERT_FALSE(search_res.ok());
ASSERT_EQ("Field `embedding` is marked as a non-indexed field in the schema.", search_res.error());
+}
+
+TEST_F(CollectionVectorTest, TestSearchNonIndexedVectorField) {
+ nlohmann::json schema = R"({
+ "name": "test",
+ "fields": [
+ {
+ "name": "vec",
+ "type": "float[]",
+ "index": false,
+ "optional": true,
+ "num_dim": 2
+ }
+ ]
+ })"_json;
+
+ 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"({
+ "vec": [0.1, 0.2]
+ })"_json.dump());
+
+ ASSERT_TRUE(add_op.ok());
+
+ auto search_result = coll->search("*", {}, "", {}, {}, {0}, 10, 1, FREQUENCY, {true}, Index::DROP_TOKENS_THRESHOLD,
+ spp::sparse_hash_set<std::string>(),
+ spp::sparse_hash_set<std::string>(), 10, "", 30, 5,
+ "", 10, {}, {}, {}, 0,
+ "<mark>", "</mark>", {}, 1000, true, false, true, "", false, 6000 * 1000, 4, 7, fallback,
+ 4, {off}, 32767, 32767, 2,
+ false, true, "vec:([0.96826, 0.94])");
+
+ ASSERT_FALSE(search_result.ok());
+ ASSERT_EQ("Field `vec` is marked as a non-indexed field in the schema.", search_result.error());
}
\ No newline at end of file