From e54f680b224d3feb7c788651365c3bbafef40ecf Mon Sep 17 00:00:00 2001 From: ozanarmagan Date: Sun, 24 Sep 2023 14:52:48 +0300 Subject: [PATCH] Add test for one embedding and one keyword field that have same prefix --- test/collection_vector_search_test.cpp | 45 ++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/collection_vector_search_test.cpp b/test/collection_vector_search_test.cpp index cacfb978..ea22f823 100644 --- a/test/collection_vector_search_test.cpp +++ b/test/collection_vector_search_test.cpp @@ -2077,4 +2077,49 @@ TEST_F(CollectionVectorTest, TestTwoEmbeddingFieldsSamePrefix) { 0, spp::sparse_hash_set()); ASSERT_TRUE(semantic_results.ok()); +} + +TEST_F(CollectionVectorTest, TestOneEmbeddingOneKeywordFieldsHaveSamePrefix) { + nlohmann::json schema = R"({ + "name": "test", + "fields": [ + { + "name": "title", + "type": "string" + }, + { + "name": "title_vec", + "type": "float[]", + "embed": { + "from": [ + "title" + ], + "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 coll1 = collection_create_op.get(); + + auto add_op = coll1->add(R"({ + "title": "john doe" + })"_json.dump()); + + ASSERT_TRUE(add_op.ok()); + + auto keyword_results = coll1->search("john", {"title"}, + "", {}, {}, {2}, 10, + 1, FREQUENCY, {true}, + 0, spp::sparse_hash_set()); + + ASSERT_TRUE(keyword_results.ok()); } \ No newline at end of file