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

Ability to restrict multi searches to a given value

Jason Boscod3a997131495
diff --git a/src/core_api.cpp b/src/core_api.cpp
index 2c9ff9a4..ab0d750e 100644
--- a/src/core_api.cpp
+++ b/src/core_api.cpp
@@ -297,6 +297,18 @@ bool post_multi_search(http_req& req, http_res& res) {
return false;
}
+ const char* LIMIT_MULTI_SEARCHES = "limit_multi_searches";
+ size_t limit_multi_searches = 50;
+
+ if(req.params.count(LIMIT_MULTI_SEARCHES) != 0 && StringUtils::is_uint32_t(req.params[LIMIT_MULTI_SEARCHES])) {
+ limit_multi_searches = std::stoi(req.params[LIMIT_MULTI_SEARCHES]);
+ }
+
+ if(req_json["searches"].size() > limit_multi_searches) {
+ res.set_400(std::string("Number of multi searches exceeds `") + LIMIT_MULTI_SEARCHES + "` parameter.");
+ return false;
+ }
+
auto orig_req_params = req.params;
nlohmann::json response;