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

adding test for facet sort with facet query

krunalfd9bde7049b8
diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cpp
index e26d6e91..8f3e03cd 100644
--- a/test/collection_faceting_test.cpp
+++ b/test/collection_faceting_test.cpp
@@ -2481,6 +2481,25 @@ TEST_F(CollectionFacetingTest, FacetSortValidation) {
ASSERT_EQ("Fusion Plus", results["facet_counts"][0]["counts"][0]["value"]);
ASSERT_EQ("Oneplus 11R", results["facet_counts"][0]["counts"][1]["value"]);
ASSERT_EQ("S22 Ultra", results["facet_counts"][0]["counts"][2]["value"]);
+
+ //facet sort with facet query should work
+ search_op = coll1->search("*", query_fields, "", {"phone(sort_by:_alpha:desc)"},
+ sort_fields, {0}, 10, 1, FREQUENCY,{false},
+ Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),
+ spp::sparse_hash_set<std::string>(),10, "phone: plus",
+ 30UL, 4UL,"", 1UL,
+ "", "", {}, 3UL, "<mark>",
+ "</mark>", {},4294967295UL, true,
+ false, true, "", false, 6000000UL,
+ 4UL,7UL, fallback, 4UL, {off}, 32767UL,
+ 32767UL, 2UL, 2UL, false,
+ "", true, 0UL, max_score, 100UL,
+ 0UL, 4294967295UL, HASH);
+
+ results = search_op.get();
+ ASSERT_EQ(1, results["facet_counts"].size());
+ ASSERT_EQ(1, results["facet_counts"][0]["counts"].size());
+ ASSERT_EQ("Fusion Plus", results["facet_counts"][0]["counts"][0]["value"]);
}
TEST_F(CollectionFacetingTest, FhashInt64MapTest) {
diff --git a/test/collection_optimized_faceting_test.cpp b/test/collection_optimized_faceting_test.cpp
index 95a80eec..55afc9fd 100644
--- a/test/collection_optimized_faceting_test.cpp
+++ b/test/collection_optimized_faceting_test.cpp
@@ -2136,6 +2136,25 @@ TEST_F(CollectionOptimizedFacetingTest, FacetSortValidation) {
ASSERT_EQ("Fusion Plus", results["facet_counts"][0]["counts"][0]["value"]);
ASSERT_EQ("Oneplus 11R", results["facet_counts"][0]["counts"][1]["value"]);
ASSERT_EQ("S22 Ultra", results["facet_counts"][0]["counts"][2]["value"]);
+
+ //facet sort with facet query should work
+ search_op = coll1->search("*", query_fields, "", {"phone(sort_by:_alpha:desc)"},
+ sort_fields, {0}, 10, 1, FREQUENCY,{false},
+ Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),
+ spp::sparse_hash_set<std::string>(),10, "phone: plus",
+ 30UL, 4UL,"", 1UL,
+ "", "", {}, 3UL, "<mark>",
+ "</mark>", {},4294967295UL, true,
+ false, true, "", false, 6000000UL,
+ 4UL,7UL, fallback, 4UL, {off}, 32767UL,
+ 32767UL, 2UL, 2UL, false,
+ "", true, 0UL, max_score, 100UL,
+ 0UL, 4294967295UL, VALUE);
+
+ results = search_op.get();
+ ASSERT_EQ(1, results["facet_counts"].size());
+ ASSERT_EQ(1, results["facet_counts"][0]["counts"].size());
+ ASSERT_EQ("Fusion Plus", results["facet_counts"][0]["counts"][0]["value"]);
}
TEST_F(CollectionOptimizedFacetingTest, ValueIndexStatsMinMax) {