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
Clearer error message about group limit range.
kishorenc0f38242e09e9
diff --git a/include/collection.h b/include/collection.hindex 730bad63..69f15832 100644--- a/include/collection.h+++ b/include/collection.h@@ -273,6 +273,8 @@ public:const size_t PER_PAGE_MAX = 250;+ const size_t GROUP_LIMIT_MAX = 99;+// Using a $ prefix so that these meta keys stay above record entries in a lexicographically ordered KV storestatic constexpr const char* COLLECTION_META_PREFIX = "$CM";static constexpr const char* COLLECTION_NEXT_SEQ_PREFIX = "$CS";diff --git a/src/collection.cpp b/src/collection.cppindex 3e5a031e..e3724a11 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -394,8 +394,9 @@ Option<nlohmann::json> Collection::search(const std::string & query, const std::return Option<nlohmann::json>(400, "No search fields specified for the query.");}- if(!group_by_fields.empty() && (group_limit == 0 || group_limit >= 100)) {- return Option<nlohmann::json>(400, "Value of `group_limit` is invalid.");+ if(!group_by_fields.empty() && (group_limit == 0 || group_limit > GROUP_LIMIT_MAX)) {+ return Option<nlohmann::json>(400, "Value of `group_limit` must be between 1 and " ++ std::to_string(GROUP_LIMIT_MAX) + ".");}std::vector<uint32_t> excluded_ids;diff --git a/test/collection_grouping_test.cpp b/test/collection_grouping_test.cppindex 63118a4e..9d02e0a8 100644--- a/test/collection_grouping_test.cpp+++ b/test/collection_grouping_test.cpp@@ -232,7 +232,7 @@ TEST_F(CollectionGroupingTest, GroupingCompoundKey) {{}, {}, {"rating"}, 100);ASSERT_FALSE(res_op.ok());- ASSERT_STREQ("Value of `group_limit` is invalid.", res_op.error().c_str());+ ASSERT_STREQ("Value of `group_limit` must be between 1 and 99.", res_op.error().c_str());res_op = coll_group->search("*", {}, "", {"brand"}, {}, 0, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,@@ -242,7 +242,7 @@ TEST_F(CollectionGroupingTest, GroupingCompoundKey) {{}, {}, {"rating"}, 0);ASSERT_FALSE(res_op.ok());- ASSERT_STREQ("Value of `group_limit` is invalid.", res_op.error().c_str());+ ASSERT_STREQ("Value of `group_limit` must be between 1 and 99.", res_op.error().c_str());}TEST_F(CollectionGroupingTest, GroupingWithGropLimitOfOne) {