mirror of
https://github.com/typesense/typesense.git
synced 2025-05-26 08:44:09 +08:00
Ability to restrict multi searches to a given value
This commit is contained in:
parent
047ad37991
commit
d3a9971314
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user