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

Use 408 for search cutoff + no results.

Kishore Nallanbfb6e6576469
diff --git a/src/collection.cpp b/src/collection.cpp
index 1b05ff12..a027d33b 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -1302,7 +1302,7 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query,
if(search_cutoff && total_found == 0) {
// this can happen if other requests stopped this request from being processed
// we should return an error so that request can be retried by client
- return Option<nlohmann::json>(529, "Site is overloaded");
+ return Option<nlohmann::json>(408, "Request Timeout");
}
if(match_score_index >= 0 && sort_fields_std[match_score_index].text_match_buckets > 1) {
diff --git a/src/core_api.cpp b/src/core_api.cpp
index 31552463..389d3904 100644
--- a/src/core_api.cpp
+++ b/src/core_api.cpp
@@ -392,7 +392,7 @@ bool get_search(const std::shared_ptr<http_req>& req, const std::shared_ptr<http
if(!search_op.ok()) {
res->set(search_op.code(), search_op.error());
- if(search_op.code() == 529) {
+ if(search_op.code() == 408) {
req->overloaded = true;
}
return false;
@@ -565,7 +565,7 @@ bool post_multi_search(const std::shared_ptr<http_req>& req, const std::shared_p
if(search_op.ok()) {
response["results"].push_back(nlohmann::json::parse(results_json_str));
} else {
- if(search_op.code() == 529) {
+ if(search_op.code() == 408) {
res->set(search_op.code(), search_op.error());
req->overloaded = true;
return false;
diff --git a/test/collection_specific_more_test.cpp b/test/collection_specific_more_test.cpp
index f5960c58..608c5fea 100644
--- a/test/collection_specific_more_test.cpp
+++ b/test/collection_specific_more_test.cpp
@@ -1778,7 +1778,8 @@ TEST_F(CollectionSpecificMoreTest, SearchCutoffTest) {
"<mark>", "</mark>", {}, 1000, true, false, true, "", false, 1);
ASSERT_FALSE(coll_op.ok());
- ASSERT_EQ("Site is overloaded", coll_op.error());
+ ASSERT_EQ("Request Timeout", coll_op.error());
+ ASSERT_EQ(408, coll_op.code());
}
TEST_F(CollectionSpecificMoreTest, CrossFieldTypoAndPrefixWithWeights) {