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
correct error code while deleting stopwords
krunal4790cbbb3bd3
diff --git a/src/core_api.cpp b/src/core_api.cppindex fbf394ab..2ef4f656 100644--- a/src/core_api.cpp+++ b/src/core_api.cpp@@ -2238,7 +2238,7 @@ bool del_stopword(const std::shared_ptr<http_req>& req, const std::shared_ptr<htOption<bool> delete_op = stopwordManager.delete_stopword(stopword_name);if(!delete_op.ok()) {- res->set_500(delete_op.error());+ res->set(delete_op.code(), delete_op.error());return false;}diff --git a/src/stopwords_manager.cpp b/src/stopwords_manager.cppindex 8e37a0be..30744e46 100644--- a/src/stopwords_manager.cpp+++ b/src/stopwords_manager.cpp@@ -80,16 +80,17 @@ std::string StopwordsManager::get_stopword_key(const std::string& stopword_name)Option<bool> StopwordsManager::delete_stopword(const std::string& stopword_name) {std::unique_lock lock(mutex);- bool removed = store->remove(get_stopword_key(stopword_name));- if(!removed) {- return Option<bool>(500, "Unable to delete from store.");- }-if(stopword_configs.find(stopword_name) == stopword_configs.end()) {return Option<bool>(404, "Stopword `" + stopword_name + "` not found.");}stopword_configs.erase(stopword_name);++ bool removed = store->remove(get_stopword_key(stopword_name));+ if(!removed) {+ return Option<bool>(500, "Unable to delete from store.");+ }+return Option<bool>(true);}diff --git a/test/stopwords_manager_test.cpp b/test/stopwords_manager_test.cppindex 8e6c8af1..ee1a03ac 100644--- a/test/stopwords_manager_test.cpp+++ b/test/stopwords_manager_test.cpp@@ -281,7 +281,7 @@ TEST_F(StopwordsManagerTest, StopwordsBasics) {req->params["name"] = "state";result = del_stopword(req, res);- ASSERT_EQ(500, res->status_code);+ ASSERT_EQ(404, res->status_code);ASSERT_STREQ("{\"message\": \"Stopword `state` not found.\"}", res->body.c_str());req->params.clear();