Skip to content

Throw an exception on unsuccessful bulk operations #1123

Open
@babenkoivan

Description

@babenkoivan

Summary of problem or feature request

Bulk API returns 200 status code even in case some operations have failed, but the response body contains a flag (errors=false), which can be used to identify the overall request result. See more details in the official ES documentation.

This is very inconvenient to parse the response in every project and check if there were errors or not. It would be really nice to get some generic exception when one or more operations did not complete successfully. It can be configurable if this matters.

Code snippet of problem

Here is an example of unsuccessful bulk indexing:

{
   "took":1,
   "errors":true,
   "items":[
      {
         "index":{
            "_index":"books",
            "_type":"_doc",
            "_id":"2",
            "status":400,
            "error":{
               "type":"mapper_parsing_exception",
               "reason":"failed to parse field [published] of type [date] in document with id '2'. Preview of field's value: '2020'",
               "caused_by":{
                  "type":"illegal_argument_exception",
                  "reason":"failed to parse date field [2020] with format [yyyy-MM-dd]",
                  "caused_by":{
                     "type":"date_time_parse_exception",
                     "reason":"Text '2020' could not be parsed at index 4"
                  }
               }
            }
         }
      }
   ]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions