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

Add cache_ttl protection for multi search.

Kishore Nallan34e5221d9449
diff --git a/src/core_api.cpp b/src/core_api.cpp
index 43effbf9..cdf67adf 100644
--- a/src/core_api.cpp
+++ b/src/core_api.cpp
@@ -362,6 +362,11 @@ bool post_multi_search(const std::shared_ptr<http_req>& req, const std::shared_p
req->params = orig_req_params;
for(auto& search_item: search_params.items()) {
+ if(search_item.key() == "cache_ttl") {
+ // cache ttl can be applied only from an embedded key: cannot be a multi search param
+ continue;
+ }
+
// overwrite = false since req params will contain embedded params and so has higher priority
bool populated = AuthManager::add_item_to_params(req->params, search_item, false);
if(!populated) {
diff --git a/src/http_server.cpp b/src/http_server.cpp
index ef7b0001..a62cd477 100644
--- a/src/http_server.cpp
+++ b/src/http_server.cpp
@@ -351,7 +351,7 @@ int HttpServer::catch_all_handler(h2o_handler_t *_h2o_handler, h2o_req_t *req) {
std::map<std::string, std::string> query_map;
StringUtils::parse_query_string(query_str, query_map);
- // cache ttl can be applied only from an embedded key
+ // cache ttl can be applied only from an embedded key: cannot be a get param
query_map.erase("cache_ttl");
// Extract auth key from header. If that does not exist, look for a GET parameter.