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
Support limit_multi_searches as regular req param.
Kishore Nallan8aa2c5e07367
diff --git a/src/core_api.cpp b/src/core_api.cppindex 08e9567b..e9346fe9 100644--- a/src/core_api.cpp+++ b/src/core_api.cpp@@ -407,9 +407,15 @@ bool post_multi_search(const std::shared_ptr<http_req>& req, const std::shared_preturn false;}+ auto orig_req_params = req->params;const char* LIMIT_MULTI_SEARCHES = "limit_multi_searches";size_t limit_multi_searches = 50;+ if(orig_req_params.count(LIMIT_MULTI_SEARCHES) != 0 &&+ StringUtils::is_uint32_t(orig_req_params[LIMIT_MULTI_SEARCHES])) {+ limit_multi_searches = std::stoi(orig_req_params[LIMIT_MULTI_SEARCHES]);+ }+const auto& first_embedded_param = req->embedded_params_vec[0];if(first_embedded_param.count(LIMIT_MULTI_SEARCHES) != 0 && first_embedded_param[LIMIT_MULTI_SEARCHES].is_number_integer()) {limit_multi_searches = first_embedded_param[LIMIT_MULTI_SEARCHES].get<size_t>();@@ -420,8 +426,6 @@ bool post_multi_search(const std::shared_ptr<http_req>& req, const std::shared_preturn false;}- auto orig_req_params = req->params;-nlohmann::json response;response["results"] = nlohmann::json::array();diff --git a/test/core_api_utils_test.cpp b/test/core_api_utils_test.cppindex 73dd887b..4a979c74 100644--- a/test/core_api_utils_test.cpp+++ b/test/core_api_utils_test.cpp@@ -207,6 +207,17 @@ TEST_F(CoreAPIUtilsTest, MultiSearchEmbeddedKeys) {req->embedded_params_vec[0]["limit_multi_searches"] = 1;ASSERT_TRUE(post_multi_search(req, res));++ // req params must be overridden by embedded param+ req->embedded_params_vec[0]["limit_multi_searches"] = 0;+ req->params["limit_multi_searches"] = "100";+ ASSERT_FALSE(post_multi_search(req, res));+ ASSERT_EQ("{\"message\": \"Number of multi searches exceeds `limit_multi_searches` parameter.\"}", res->body);++ // use req params if embedded param not present+ req->embedded_params_vec[0].erase("limit_multi_searches");+ ASSERT_TRUE(post_multi_search(req, res));+}TEST_F(CoreAPIUtilsTest, ExtractCollectionsFromRequestBody) {