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
add test facet query with multiple tokens to hash index tests
krunalb3a94888eb04
diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cppindex 8ffa31c8..e26d6e91 100644--- a/test/collection_faceting_test.cpp+++ b/test/collection_faceting_test.cpp@@ -776,6 +776,60 @@ TEST_F(CollectionFacetingTest, FacetCountOnSimilarStrings) {collectionManager.drop_collection("coll1");}+TEST_F(CollectionFacetingTest, FacetQueryTest) {+ std::vector<field> fields = {+ field("color", field_types::STRING, true),+ };++ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields).get();+ std::vector<std::string> colors = {"apple red", "azure", "amazon green", "apricot orange",+ "blue", "barrel blue", "banana yellow", "ball green", "baikal"};++ for(size_t i = 0; i < 100; i++) {+ nlohmann::json doc;+ doc["color"] = colors[i % colors.size()];+ ASSERT_TRUE(coll1->add(doc.dump()).ok());+ }++ // add colors that DON'T start with "b" to push these up the count list+ for(size_t i = 0; i < 4; i++) {+ nlohmann::json doc;+ doc["color"] = colors[i];+ ASSERT_TRUE(coll1->add(doc.dump()).ok());+ }++ auto results = coll1->search("*", {},+ "", {"color"}, {}, {2}, 1, 1, FREQUENCY, {true}, 1, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 5, "color:b", 30, 4, "", 20, {}, {}, {}, 0,+ "<mark>", "</mark>", {}, 1000, true, false, true, "", false, 6000 * 1000, 4, 7, fallback,+ 4, {off}, 3, 3, 2, 2, false, "", true, 0, max_score, 100, 0, 4294967295UL, VALUE).get();+++ ASSERT_EQ(1, results["facet_counts"].size());+ ASSERT_EQ(4, results["facet_counts"][0]["counts"].size()); // 4 is default candidate size++ // junk string should produce no facets++ results = coll1->search("*", {},+ "", {"color"}, {}, {2}, 1, 1, FREQUENCY, {true}, 1, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 5, "color:xsda", 30, 4, "", 20, {}, {}, {}, 0,+ "<mark>", "</mark>", {}, 1000, true, false, true, "", false, 6000 * 1000, 4, 7, fallback,+ 4, {off}, 3, 3, 2, 2, false, "", true, 0, max_score, 100, 0, 4294967295UL, VALUE).get();+ ASSERT_EQ(1, results["facet_counts"].size());+ ASSERT_EQ(0, results["facet_counts"][0]["counts"].size());++ results = coll1->search("*", {},+ "", {"color"}, {}, {2}, 1, 1, FREQUENCY, {true}, 1, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 5, "color:green a", 30, 4, "", 20, {}, {}, {}, 0,+ "<mark>", "</mark>", {}, 1000, true, false, true, "", false, 6000 * 1000, 4, 7, fallback,+ 4, {off}, 3, 3, 2, 2, false, "", true, 0, max_score, 100, 0, 4294967295UL, VALUE).get();++ ASSERT_EQ(1, results["facet_counts"].size());+ ASSERT_EQ(1, results["facet_counts"][0]["counts"].size());+ ASSERT_EQ("amazon green", results["facet_counts"][0]["counts"][0]["value"]);+ ASSERT_EQ("<mark>a</mark>mazon <mark>green</mark>", results["facet_counts"][0]["counts"][0]["highlighted"]);+}+TEST_F(CollectionFacetingTest, FacetQueryOnStringWithColon) {std::vector<field> fields = {field("title", field_types::STRING, true),field("points", field_types::INT32, false)};diff --git a/test/collection_optimized_faceting_test.cpp b/test/collection_optimized_faceting_test.cppindex 702a6430..9a9f76fa 100644--- a/test/collection_optimized_faceting_test.cpp+++ b/test/collection_optimized_faceting_test.cpp@@ -1400,6 +1400,7 @@ TEST_F(CollectionOptimizedFacetingTest, FacetQueryTest) {ASSERT_EQ(1, results["facet_counts"].size());ASSERT_EQ(1, results["facet_counts"][0]["counts"].size());ASSERT_EQ("amazon green", results["facet_counts"][0]["counts"][0]["value"]);+ ASSERT_EQ("<mark>a</mark>mazon <mark>green</mark>", results["facet_counts"][0]["counts"][0]["highlighted"]);}TEST_F(CollectionOptimizedFacetingTest, StringLengthTest) {