Unexpected result status for bulk if contained delete failed


(Gunnar Morling) #1

Hi,

I am executing bulk requests which contain delete operations. When any of the deletes fails because I'm trying to delete a non-existing document, that item is reported in the response with status 404, but the overall status of the bulk request still is "errors" : false.

Is this an expected behavior? Cheaper in bulk seems to indicate otherwise:

If any of the requests fail, the top-level error flag is set to true

Interestingly, no error is set to the item itself, apart from the 404 status.

These are my requests:

curl -XPUT "http://localhost:9200/movies"
curl -XPUT "http://localhost:9200/movies/movie/1" -d '{}'
curl -XPUT "http://localhost:9200/movies/movie/2" -d '{}'

File "bulk.json" with following contents:

{ "delete": { "_index": "movies", "_type": "movie", "_id": "1" } }
{ "delete": { "_index": "movies", "_type": "movie", "_id": "3" } }

Running the bulk request:

curl -v -XPOST "http://localhost:9200/_bulk" --data-binary @bulk.json

And that's the reply from the bulk request:

{
  "took": 7,
  "errors": false,
  "items": [
    {
      "delete": {
        "_index": "movies",
        "_type": "movie",
        "_id": "1",
        "_version": 2,
        "_shards": {
          "total": 1,
          "successful": 1,
          "failed": 0
        },
        "status": 200,
        "found": true
      }
    },
    {
      "delete": {
        "_index": "movies",
        "_type": "movie",
        "_id": "3",
        "_version": 1,
        "_shards": {
          "total": 1,
          "successful": 1,
          "failed": 0
        },
        "status": 404,
        "found": false
      }
    }
  ]
}

It's working as expected for other kinds of errors, e.g. when provoking a 409 by trying to create an already existing document. In this case I see an error at the level of the concerned item and the overall errors flag is set to true. I am using Elasticsearch 2.2.

Any help is appreciated very much!

Thanks,

--Gunnar


(system) #2