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

Fix tests.

Harpreet Sangar0059f8d3fb95
diff --git a/test/collection_join_test.cpp b/test/collection_join_test.cpp
index 9f22cdda..b25439e6 100644
--- a/test/collection_join_test.cpp
+++ b/test/collection_join_test.cpp
@@ -710,145 +710,3 @@ TEST_F(CollectionJoinTest, IncludeFieldsByReference_SingleMatch) {
// ASSERT_EQ(5, res_obj["hits"][0]["document"].size());
// ASSERT_EQ(1, res_obj["hits"][0]["document"].count("product_id_sequence_id"));
}
-
-TEST_F(CollectionJoinTest, FilterByReferenceField_MultipleMatch) {
- auto schema_json =
- R"({
- "name": "Users",
- "fields": [
- {"name": "user_id", "type": "string"},
- {"name": "user_name", "type": "string"}
- ]
- })"_json;
- std::vector<nlohmann::json> documents = {
- R"({
- "user_id": "user_a",
- "user_name": "Roshan"
- })"_json,
- R"({
- "user_id": "user_b",
- "user_name": "Ruby"
- })"_json,
- R"({
- "user_id": "user_c",
- "user_name": "Joe"
- })"_json,
- R"({
- "user_id": "user_d",
- "user_name": "Aby"
- })"_json
- };
- auto collection_create_op = collectionManager.create_collection(schema_json);
- ASSERT_TRUE(collection_create_op.ok());
- for (auto const &json: documents) {
- auto add_op = collection_create_op.get()->add(json.dump());
- if (!add_op.ok()) {
- LOG(INFO) << add_op.error();
- }
- ASSERT_TRUE(add_op.ok());
- }
-
- schema_json =
- R"({
- "name": "Repos",
- "fields": [
- {"name": "repo_id", "type": "string"},
- {"name": "repo_content", "type": "string"}
- ]
- })"_json;
- documents = {
- R"({
- "repo_id": "repo_a",
- "repo_content": "body1"
- })"_json,
- R"({
- "repo_id": "repo_b",
- "repo_content": "body2"
- })"_json,
- R"({
- "repo_id": "repo_c",
- "repo_content": "body3"
- })"_json
- };
- collection_create_op = collectionManager.create_collection(schema_json);
- ASSERT_TRUE(collection_create_op.ok());
- for (auto const &json: documents) {
- auto add_op = collection_create_op.get()->add(json.dump());
- if (!add_op.ok()) {
- LOG(INFO) << add_op.error();
- }
- ASSERT_TRUE(add_op.ok());
- }
-
- schema_json =
- R"({
- "name": "Links",
- "fields": [
- {"name": "repo_id", "type": "string", "reference": "Repos.repo_id"},
- {"name": "user_id", "type": "string", "reference": "Users.user_id"}
- ]
- })"_json;
- documents = {
- R"({
- "repo_id": "repo_a",
- "user_id": "user_b"
- })"_json,
- R"({
- "repo_id": "repo_a",
- "user_id": "user_c"
- })"_json,
- R"({
- "repo_id": "repo_b",
- "user_id": "user_a"
- })"_json,
- R"({
- "repo_id": "repo_b",
- "user_id": "user_b"
- })"_json,
- R"({
- "repo_id": "repo_b",
- "user_id": "user_d"
- })"_json,
- R"({
- "repo_id": "repo_c",
- "user_id": "user_a"
- })"_json,
- R"({
- "repo_id": "repo_c",
- "user_id": "user_b"
- })"_json,
- R"({
- "repo_id": "repo_c",
- "user_id": "user_c"
- })"_json,
- R"({
- "repo_id": "repo_c",
- "user_id": "user_d"
- })"_json
- };
- collection_create_op = collectionManager.create_collection(schema_json);
- ASSERT_TRUE(collection_create_op.ok());
-
- for (auto const &json: documents) {
- auto add_op = collection_create_op.get()->add(json.dump());
- if (!add_op.ok()) {
- LOG(INFO) << add_op.error();
- }
- ASSERT_TRUE(add_op.ok());
- }
-
- auto coll = collectionManager.get_collection("Users");
-
- // Search for users linked to repo_b
- auto result = coll->search("R", {"user_name"}, "$Links(repo_id:=repo_b)", {}, {}, {0},
- 10, 1, FREQUENCY, {true}, Index::DROP_TOKENS_THRESHOLD).get();
-
- ASSERT_EQ(2, result["found"].get<size_t>());
- ASSERT_EQ(2, result["hits"].size());
- ASSERT_EQ("user_b", result["hits"][0]["document"]["user_id"].get<std::string>());
- ASSERT_EQ("user_a", result["hits"][1]["document"]["user_id"].get<std::string>());
-
-// collectionManager.drop_collection("Users");
-// collectionManager.drop_collection("Repos");
-// collectionManager.drop_collection("Links");
-}
\ No newline at end of file