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

Merge branch 'v0.25-join' of https://github.com/ozanarmagan/typesense into v0.25-join

ozanarmagan992ff2d9ad13
diff --cc test/collection_vector_search_test.cpp
index b6f305e6,b6b598dc..f5fd9ab2
--- a/test/collection_vector_search_test.cpp
+++ b/test/collection_vector_search_test.cpp
@@@ -723,23 -709,44 +723,55 @@@ TEST_F(CollectionVectorTest, HybridSear
"<mark>", "</mark>", {}, 1000, true, false, true, "", false, 6000 * 1000, 4, 7,
fallback,
4, {off}, 32767, 32767, 2,
- false, true, "vec:(" + dummy_vec_string +")");
+ false, true, "vec:(" + vec_string + ")");
ASSERT_EQ(true, results_op.ok());
- ASSERT_EQ(1, results_op.get()["found"].get<size_t>());
- ASSERT_EQ(1, results_op.get()["hits"].size());
+
+
+ ASSERT_EQ(3, results_op.get()["found"].get<size_t>());
+ ASSERT_EQ(3, results_op.get()["hits"].size());
+
+ // order:
+ // 1. jim halpert
+ // 2. michael scott
+ // 3. pam beesly
+
+ ASSERT_EQ("jim halpert", results_op.get()["hits"][0]["document"]["name"].get<std::string>());
+ ASSERT_EQ("micheal scott", results_op.get()["hits"][1]["document"]["name"].get<std::string>());
+ ASSERT_EQ("pam beesly", results_op.get()["hits"][2]["document"]["name"].get<std::string>());
}
+ TEST_F(CollectionVectorTest, HybridSearchOnlyVectorMatches) {
+ nlohmann::json schema = R"({
+ "name": "coll1",
+ "fields": [
+ {"name": "name", "type": "string", "facet": true},
+ {"name": "vec", "type": "float[]", "embed":{"from": ["name"], "model_config": {"model_name": "ts/e5-small"}}}
+ ]
+ })"_json;
+
+ TextEmbedderManager::set_model_dir("/tmp/typesense_test/models");
+ Collection* coll1 = collectionManager.create_collection(schema).get();
+
+ nlohmann::json doc;
+ doc["name"] = "john doe";
+ ASSERT_TRUE(coll1->add(doc.dump()).ok());
+
+ auto results_op = coll1->search("zzz", {"name", "vec"}, "", {"name"}, {}, {0}, 20, 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);
+ ASSERT_EQ(true, results_op.ok());
+ ASSERT_EQ(1, results_op.get()["found"].get<size_t>());
+ ASSERT_EQ(1, results_op.get()["hits"].size());
+ ASSERT_EQ(1, results_op.get()["facet_counts"].size());
+ ASSERT_EQ(4, results_op.get()["facet_counts"][0].size());
+ ASSERT_EQ("name", results_op.get()["facet_counts"][0]["field_name"]);
+ }
+
TEST_F(CollectionVectorTest, DistanceThresholdTest) {
nlohmann::json schema = R"({
"name": "test",