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
Fix test ordering.
kishorenc53eb2e6cbd0f
diff --git a/include/collection.h b/include/collection.hindex 29984509..4fa1fc2a 100644--- a/include/collection.h+++ b/include/collection.h@@ -351,7 +351,13 @@ private:static bool facet_count_str_compare(const facet_value_t& a,const facet_value_t& b) {- return a.count > b.count;+ size_t a_count = a.count;+ size_t b_count = b.count;++ size_t a_value_size = UINT64_MAX - a.value.size();+ size_t b_value_size = UINT64_MAX - b.value.size();++ return std::tie(a_count, a_value_size) > std::tie(b_count, b_value_size);}void free_leaf_indices(std::vector<uint32_t*>& leaf_to_indices) const;diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cppindex e192a2c2..be2dfdff 100644--- a/test/collection_faceting_test.cpp+++ b/test/collection_faceting_test.cpp@@ -245,10 +245,10 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("tags", results["facet_counts"][0]["field_name"].get<std::string>().c_str());ASSERT_EQ(2, results["facet_counts"][0]["counts"].size());- ASSERT_STREQ("silver", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());+ ASSERT_STREQ("gold", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());ASSERT_EQ(3, (int) results["facet_counts"][0]["counts"][0]["count"]);- ASSERT_STREQ("gold", results["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());+ ASSERT_STREQ("silver", results["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());ASSERT_EQ(3, (int) results["facet_counts"][0]["counts"][1]["count"]);// 2 facets, 1 text query with no filters@@ -283,8 +283,8 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("silver", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());ASSERT_STREQ("gold", results["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());- ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());- ASSERT_STREQ("bronze", results["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());+ ASSERT_STREQ("bronze", results["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());+ ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());// facet with wildcard queryfacets.clear();@@ -302,8 +302,8 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("silver", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());ASSERT_STREQ("gold", results["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());- ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());- ASSERT_STREQ("bronze", results["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());+ ASSERT_STREQ("bronze", results["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());+ ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());// facet with facet filter query (allows typo correction!)results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,@@ -676,8 +676,8 @@ TEST_F(CollectionFacetingTest, FacetCountsHighlighting) {ASSERT_EQ(3, results["facet_counts"][0]["counts"].size());ASSERT_STREQ("<mark>Cell</mark> Phones", results["facet_counts"][0]["counts"][0]["highlighted"].get<std::string>().c_str());- ASSERT_STREQ("<mark>Cell</mark> Phone Accessories", results["facet_counts"][0]["counts"][1]["highlighted"].get<std::string>().c_str());- ASSERT_STREQ("<mark>Cello</mark>phanes", results["facet_counts"][0]["counts"][2]["highlighted"].get<std::string>().c_str());+ ASSERT_STREQ("<mark>Cello</mark>phanes", results["facet_counts"][0]["counts"][1]["highlighted"].get<std::string>().c_str());+ ASSERT_STREQ("<mark>Cell</mark> Phone Accessories", results["facet_counts"][0]["counts"][2]["highlighted"].get<std::string>().c_str());collectionManager.drop_collection("coll1");}diff --git a/test/collection_grouping_test.cpp b/test/collection_grouping_test.cppindex 6f35b2da..b6e1df35 100644--- a/test/collection_grouping_test.cpp+++ b/test/collection_grouping_test.cpp@@ -91,10 +91,10 @@ TEST_F(CollectionGroupingTest, GroupingBasics) {ASSERT_STREQ("brand", res["facet_counts"][0]["field_name"].get<std::string>().c_str());ASSERT_EQ(3, (int) res["facet_counts"][0]["counts"][0]["count"]);- ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());ASSERT_EQ(3, (int) res["facet_counts"][0]["counts"][1]["count"]);- ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());ASSERT_EQ(2, (int) res["facet_counts"][0]["counts"][2]["count"]);ASSERT_STREQ("Xorp", res["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());@@ -179,10 +179,10 @@ TEST_F(CollectionGroupingTest, GroupingCompoundKey) {ASSERT_STREQ("brand", res["facet_counts"][0]["field_name"].get<std::string>().c_str());ASSERT_EQ(3, (int) res["facet_counts"][0]["counts"][0]["count"]);- ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());ASSERT_EQ(3, (int) res["facet_counts"][0]["counts"][1]["count"]);- ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());ASSERT_EQ(2, (int) res["facet_counts"][0]["counts"][2]["count"]);ASSERT_STREQ("Xorp", res["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());@@ -215,10 +215,10 @@ TEST_F(CollectionGroupingTest, GroupingCompoundKey) {ASSERT_STREQ("brand", res["facet_counts"][0]["field_name"].get<std::string>().c_str());ASSERT_EQ(3, (int) res["facet_counts"][0]["counts"][0]["count"]);- ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());ASSERT_EQ(3, (int) res["facet_counts"][0]["counts"][1]["count"]);- ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());ASSERT_EQ(2, (int) res["facet_counts"][0]["counts"][2]["count"]);ASSERT_STREQ("Xorp", res["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());@@ -417,13 +417,13 @@ TEST_F(CollectionGroupingTest, GroupingWithArrayFieldAndOverride) {ASSERT_STREQ("brand", res["facet_counts"][0]["field_name"].get<std::string>().c_str());ASSERT_EQ(2, (int) res["facet_counts"][0]["counts"][0]["count"]);- ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());ASSERT_EQ(2, (int) res["facet_counts"][0]["counts"][1]["count"]);- ASSERT_STREQ("Beta", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Xorp", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());ASSERT_EQ(2, (int) res["facet_counts"][0]["counts"][2]["count"]);- ASSERT_STREQ("Xorp", res["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());+ ASSERT_STREQ("Omega", res["facet_counts"][0]["counts"][2]["value"].get<std::string>().c_str());ASSERT_EQ(1, (int) res["facet_counts"][0]["counts"][3]["count"]);ASSERT_STREQ("Zeta", res["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());