From 1373dacb0c713191ab7a78f19760233f93604320 Mon Sep 17 00:00:00 2001 From: kishorenc Date: Wed, 9 Dec 2020 06:53:35 +0530 Subject: [PATCH] Improve upsert test case with a filter usecase. --- test/collection_test.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/collection_test.cpp b/test/collection_test.cpp index 7ecdcbf5..6760033c 100644 --- a/test/collection_test.cpp +++ b/test/collection_test.cpp @@ -983,8 +983,12 @@ TEST_F(CollectionTest, ImportDocumentsUpsert) { ASSERT_TRUE(import_response["success"].get()); ASSERT_EQ(18, import_response["num_imported"].get()); + // try searching with filter + auto results = coll_mul_fields->search("*", query_fields, "starring:= [Will Ferrell]", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get(); + ASSERT_EQ(2, results["hits"].size()); + // update + upsert records - std::vector more_records = {R"({"id": "0", "title": "The Fifth Harry"})", + std::vector more_records = {R"({"id": "0", "title": "The Fifth Harry", "starring": "Will Ferrell"})", R"({"id": "2", "cast": ["Chris Fisher", "Rand Alan"]})", R"({"id": "18", "title": "Back Again Forest", "points": 45, "starring": "Ronald Wells", "cast": ["Dant Saren"]})", R"({"id": "6", "points": 77})"}; @@ -1002,7 +1006,11 @@ TEST_F(CollectionTest, ImportDocumentsUpsert) { ASSERT_EQ(1, import_results[i].size()); } - auto results = coll_mul_fields->search("*", query_fields, "", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get(); + // try with filters again + results = coll_mul_fields->search("*", query_fields, "starring:= [Will Ferrell]", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get(); + ASSERT_EQ(2, results["hits"].size()); + + results = coll_mul_fields->search("*", query_fields, "", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get(); ASSERT_EQ(19, results["hits"].size()); ASSERT_EQ(19, coll_mul_fields->get_num_documents());