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
More pagination validation.
Kishore Nallan2474ac0625af
diff --git a/src/collection_manager.cpp b/src/collection_manager.cppindex 3231475a..f42d356a 100644--- a/src/collection_manager.cpp+++ b/src/collection_manager.cpp@@ -952,6 +952,10 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& reper_page = 0;}+ if(!req_params[PAGE].empty() && page == 0 && offset == UINT32_MAX) {+ return Option<bool>(422, "Parameter `page` must be an integer of value greater than 0.");+ }+if(req_params[PAGE].empty() && req_params[OFFSET].empty()) {page = 1;}diff --git a/test/collection_test.cpp b/test/collection_test.cppindex f9e842ab..c8b768a8 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -1058,7 +1058,6 @@ TEST_F(CollectionTest, KeywordQueryReturnsResultsBasedOnPerPageParam) {FREQUENCY, {true}, 1000, empty, empty, 10);ASSERT_FALSE(res_op.ok());ASSERT_EQ(422, res_op.code());- ASSERT_STREQ("Page must be an integer of value greater than 0.", res_op.error().c_str());// do pagination@@ -3031,7 +3030,6 @@ TEST_F(CollectionTest, WildcardQueryReturnsResultsBasedOnPerPageParam) {FREQUENCY, {false}, 1000, empty, empty, 10);ASSERT_FALSE(res_op.ok());ASSERT_EQ(422, res_op.code());- ASSERT_STREQ("Page must be an integer of value greater than 0.", res_op.error().c_str());// do paginationdiff --git a/test/core_api_utils_test.cpp b/test/core_api_utils_test.cppindex 1bf5a88b..362ef643 100644--- a/test/core_api_utils_test.cpp+++ b/test/core_api_utils_test.cpp@@ -733,6 +733,23 @@ TEST_F(CoreAPIUtilsTest, SearchPagination) {results = nlohmann::json::parse(res->body)["results"][0];ASSERT_EQ(400, results["code"].get<size_t>());ASSERT_EQ("Parameter `offset` must be an unsigned integer.", results["error"].get<std::string>());++ // when page is 0 and no offset is sent+ search.clear();+ req->params.clear();+ body["searches"] = nlohmann::json::array();+ search["collection"] = "coll1";+ search["q"] = "title";+ search["page"] = "0";+ search["query_by"] = "name";+ search["sort_by"] = "points:desc";+ body["searches"].push_back(search);+ req->body = body.dump();++ post_multi_search(req, res);+ results = nlohmann::json::parse(res->body)["results"][0];+ ASSERT_EQ(422, results["code"].get<size_t>());+ ASSERT_EQ("Parameter `page` must be an integer of value greater than 0.", results["error"].get<std::string>());}TEST_F(CoreAPIUtilsTest, ExportWithFilter) {