From 391d8ed9d9682bbfc946a0c2621552056b9b6bce Mon Sep 17 00:00:00 2001 From: simon987 Date: Sun, 22 Aug 2021 08:23:20 -0400 Subject: [PATCH] Add error handling for ES mappings/settings --- src/index/elastic.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/index/elastic.c b/src/index/elastic.c index 8ff764a..dd53149 100644 --- a/src/index/elastic.c +++ b/src/index/elastic.c @@ -393,12 +393,20 @@ void elastic_init(int force_reset, const char* user_mappings, const char* user_s snprintf(url, sizeof(url), "%s/%s/_settings", IndexCtx.es_url, IndexCtx.es_index); r = web_put(url, user_settings ? user_settings : settings_json); - LOG_INFOF("elastic.c", "Update user_settings <%d>", r->status_code); + LOG_INFOF("elastic.c", "Update ES settings <%d>", r->status_code); + if (r->status_code != 200) { + print_error(r); + LOG_FATAL("elastic.c", "Could not update user settings") + } free_response(r); snprintf(url, sizeof(url), "%s/%s/_mappings/_doc?include_type_name=true", IndexCtx.es_url, IndexCtx.es_index); r = web_put(url, user_mappings ? user_mappings : mappings_json); - LOG_INFOF("elastic.c", "Update user_mappings <%d>", r->status_code); + LOG_INFOF("elastic.c", "Update ES mappings <%d>", r->status_code); + if (r->status_code != 200) { + print_error(r); + LOG_FATAL("elastic.c", "Could not update user mappings") + } free_response(r); snprintf(url, sizeof(url), "%s/%s/_open", IndexCtx.es_url, IndexCtx.es_index);