This commit is contained in:
simon 2020-02-15 19:33:18 -05:00
parent e1aaaee617
commit 849beb09d8

View File

@ -138,19 +138,21 @@ void elastic_flush() {
LOG_INFOF("elastic.c", "Indexed %d documents (%zukB) <%d>", count, buf_cur / 1024, r->status_code); LOG_INFOF("elastic.c", "Indexed %d documents (%zukB) <%d>", count, buf_cur / 1024, r->status_code);
cJSON *ret_json = cJSON_Parse(r->body); if (r->status_code != 200 && r->status_code != 413) {
if (cJSON_GetObjectItem(ret_json, "errors")->valueint != 0) { cJSON *ret_json = cJSON_Parse(r->body);
cJSON *err; if (cJSON_GetObjectItem(ret_json, "errors")->valueint != 0) {
cJSON_ArrayForEach(err, cJSON_GetObjectItem(ret_json, "items")) { cJSON *err;
if (cJSON_GetObjectItem(cJSON_GetObjectItem(err, "index"), "status")->valueint != 201) { cJSON_ArrayForEach(err, cJSON_GetObjectItem(ret_json, "items")) {
char* str = cJSON_Print(err); if (cJSON_GetObjectItem(cJSON_GetObjectItem(err, "index"), "status")->valueint != 201) {
LOG_ERRORF("elastic.c", "%s\n", str); char* str = cJSON_Print(err);
cJSON_free(str); LOG_ERRORF("elastic.c", "%s\n", str);
cJSON_free(str);
}
} }
} }
}
cJSON_Delete(ret_json); cJSON_Delete(ret_json);
}
free_response(r); free_response(r);
free(buf); free(buf);