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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
update test
krunal7426d02f79e6
diff --git a/test/analytics_manager_test.cpp b/test/analytics_manager_test.cppindex 0e247ce3..a057bd18 100644--- a/test/analytics_manager_test.cpp+++ b/test/analytics_manager_test.cpp@@ -445,6 +445,78 @@ TEST_F(AnalyticsManagerTest, NoresultsQueries) {ASSERT_EQ(0, noresults_queries.size());}+TEST_F(AnalyticsManagerTest, SuggestionConfigRule) {+ nlohmann::json titles_schema = R"({+ "name": "titles",+ "fields": [+ {"name": "title", "type": "string"}+ ]+ })"_json;++ Collection* titles_coll = collectionManager.create_collection(titles_schema).get();+++ // create a collection to store suggestions+ nlohmann::json suggestions_schema = R"({+ "name": "top_queries",+ "fields": [+ {"name": "q", "type": "string" },+ {"name": "count", "type": "int32" }+ ]+ })"_json;++ Collection* suggestions_coll = collectionManager.create_collection(suggestions_schema).get();++ //add popular quries rule+ nlohmann::json analytics_rule = R"({+ "name": "top_search_queries",+ "type": "popular_queries",+ "params": {+ "limit": 100,+ "source": {+ "collections": ["titles"]+ },+ "destination": {+ "collection": "top_queries"+ }+ }+ })"_json;++ auto create_op = analyticsManager.create_rule(analytics_rule, false, true);+ ASSERT_TRUE(create_op.ok());++ //add nohits rule+ analytics_rule = R"({+ "name": "search_queries",+ "type": "nohits_queries",+ "params": {+ "limit": 100,+ "source": {+ "collections": ["titles"]+ },+ "destination": {+ "collection": "top_queries"+ }+ }+ })"_json;++ create_op = analyticsManager.create_rule(analytics_rule, false, true);+ ASSERT_TRUE(create_op.ok());++ auto rules = analyticsManager.list_rules().get()["rules"];+ ASSERT_EQ(2, rules.size());+ ASSERT_EQ("search_queries", rules[0]["name"]);+ ASSERT_EQ("nohits_queries", rules[0]["type"]);+ ASSERT_EQ("top_search_queries", rules[1]["name"]);+ ASSERT_EQ("popular_queries", rules[1]["type"]);++ //try deleting rules+ ASSERT_TRUE(analyticsManager.remove_rule("search_queries").ok());+ ASSERT_TRUE(analyticsManager.remove_rule("top_search_queries").ok());+ rules = analyticsManager.list_rules().get()["rules"];+ ASSERT_EQ(0, rules.size());+}+TEST_F(AnalyticsManagerTest, QueryHitsCount) {//flush all events from analytics storeanalyticsManager.resetAnalyticsStore();@@ -941,70 +1013,4 @@ TEST_F(AnalyticsManagerTest, PopularityScoreValidation) {create_op = analyticsManager.create_rule(analytics_rule, false, true);ASSERT_FALSE(create_op.ok());ASSERT_EQ("counter_field `popularity_score` not found in destination collection.", create_op.error());-}--TEST_F(AnalyticsManagerTest, SuggestionConfigRule) {- nlohmann::json titles_schema = R"({- "name": "titles",- "fields": [- {"name": "title", "type": "string"}- ]- })"_json;-- Collection* titles_coll = collectionManager.create_collection(titles_schema).get();--- // create a collection to store suggestions- nlohmann::json suggestions_schema = R"({- "name": "top_queries",- "fields": [- {"name": "q", "type": "string" },- {"name": "count", "type": "int32" }- ]- })"_json;-- Collection* suggestions_coll = collectionManager.create_collection(suggestions_schema).get();-- //add popular quries rule- nlohmann::json analytics_rule = R"({- "name": "top_search_queries",- "type": "popular_queries",- "params": {- "limit": 100,- "source": {- "collections": ["titles"]- },- "destination": {- "collection": "top_queries"- }- }- })"_json;-- auto create_op = analyticsManager.create_rule(analytics_rule, false, true);- ASSERT_TRUE(create_op.ok());-- //add nohits rule- analytics_rule = R"({- "name": "search_queries",- "type": "nohits_queries",- "params": {- "limit": 100,- "source": {- "collections": ["titles"]- },- "destination": {- "collection": "top_queries"- }- }- })"_json;-- create_op = analyticsManager.create_rule(analytics_rule, false, true);- ASSERT_TRUE(create_op.ok());-- auto rules = analyticsManager.list_rules().get()["rules"];- ASSERT_EQ(2, rules.size());- ASSERT_EQ("search_queries", rules[0]["name"]);- ASSERT_EQ("nohits_queries", rules[0]["type"]);- ASSERT_EQ("top_search_queries", rules[1]["name"]);- ASSERT_EQ("popular_queries", rules[1]["type"]);}\ No newline at end of file