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

making results deterministic and consistent

krunal1313ad87ea0544de
diff --git a/include/collection.h b/include/collection.h
index 4f0db2db..3b1e0e70 100644
--- a/include/collection.h
+++ b/include/collection.h
@@ -195,7 +195,7 @@ private:
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);
+ return std::tie(a_count, a_value_size, a.value) > std::tie(b_count, b_value_size, b.value);
}
static Option<bool> parse_pinned_hits(const std::string& pinned_hits_str,
diff --git a/test/collection_optimized_faceting_test.cpp b/test/collection_optimized_faceting_test.cpp
index f4c662c2..d5e23a5d 100644
--- a/test/collection_optimized_faceting_test.cpp
+++ b/test/collection_optimized_faceting_test.cpp
@@ -673,8 +673,8 @@ TEST_F(CollectionOptimizedFacetingTest, FacetCountOnSimilarStrings) {
ASSERT_EQ(2, results["hits"].size());
ASSERT_EQ(2, results["facet_counts"][0]["counts"].size());
- ASSERT_STREQ("England in India", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());
- ASSERT_STREQ("India in England", results["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());
+ ASSERT_STREQ("India in England", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());
+ ASSERT_STREQ("England in India", results["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());
collectionManager.drop_collection("coll1");
}
diff --git a/test/collection_test.cpp b/test/collection_test.cpp
index e01e7b27..da115fd4 100644
--- a/test/collection_test.cpp
+++ b/test/collection_test.cpp
@@ -2390,10 +2390,10 @@ TEST_F(CollectionTest, UpdateDocument) {
ASSERT_STREQ("tags", res["facet_counts"][0]["field_name"].get<std::string>().c_str());
ASSERT_EQ(2, res["facet_counts"][0]["counts"].size());
- ASSERT_STREQ("LAZY", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());
+ ASSERT_STREQ("NEWS", res["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());
ASSERT_EQ(1, (int) res["facet_counts"][0]["counts"][0]["count"]);
- ASSERT_STREQ("NEWS", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());
+ ASSERT_STREQ("LAZY", res["facet_counts"][0]["counts"][1]["value"].get<std::string>().c_str());
ASSERT_EQ(1, (int) res["facet_counts"][0]["counts"][1]["count"]);
// upsert only part of the document -- document should be REPLACED