seznam / elasticlient

C++ Elasticsearch client library
https://seznam.github.io/elasticlient/
MIT License
132 stars 67 forks source link

Unsupported action found at bulk response. #29

Open johnchienbronci opened 2 years ago

johnchienbronci commented 2 years ago

Hi,

elasticlient lib version: version-02 elastic-search version: 7.17.0

I'm bulk perform fail and without error. Checking log found a msg: Unsupported 'action' found at bulk response.

deatail log:

Host response text: {
  "took": 0,
  "errors": true,
  "items": [
    {
      "create": {
        "_index": ".ds-game-of-thrones-a-2022.04.06-000032",
        "_type": "_doc",
        "_id": "docId_c",
        "status": 409,
        "error": {
          "type": "version_conflict_engine_exception",
          "reason": "[docId_c]: version conflict, document already exists (current version [1])",
          "index_uuid": "1pbbHdwvQyKv55pxEqUjjg",
          "shard": "0",
          "index": ".ds-game-of-thrones-a-2022.04.06-000032"
        }
      }
    }
  ]
}

Host response size: 406
Unsupported 'action' found at bulk response.
johnchienbronci commented 2 years ago

File: src/Bulk.cc function: processResult() Find: // process items responses and replace it

    // process items responses
    const char *itemKeyName = nullptr;
    for (const Json::Value &item: items) {
        if (!item.isObject()) {
            LOG(LogLevel::WARNING, "Bulk items responses have to be objects!");
            continue;
        }

        // check index action response
        itemKeyName = nullptr;
        if (item.isMember("index") == true) itemKeyName = "index";
        else if (item.isMember("create") == true) itemKeyName = "create";
        if (itemKeyName != nullptr) {
            const Json::Value &res = item[itemKeyName];
            if (!res.isObject()) {
                LOG(LogLevel::WARNING, "Bulk response has unexpected format, "
                                       "object was expected.");
                continue;
            }
            // read status code
            const Json::Value &status = res.get("status", Json::Int(500));
            if (!status.isNumeric()) {
                LOG(LogLevel::WARNING, "Bulk response was expected to have numeric status. "
                                       "Skipping this response checking.");
                continue;
            }

            // if status code is not 2xx family, consider it as error
            if (status.asInt() / 100 != 2) {
                errCount++;
            }
        } else {
            LOG(LogLevel::WARNING, "Unsupported 'action' found at bulk response.");

        }
    }