Elastic Search Bulk Upload is ignoring the last operation provided in the json

I'm trying to perform a Bulk Operation in elastic search. However the last operation given in the JSON is never executed by elastic search.

This is my Request:

curl -XPOST 'localhost:9200/customer/external/_bulk?pretty&pretty' -d'

{"update":{"_id":"1"}}
{"doc": { "name": "Update - John Doe becomes Jane Doe" } }

{"delete":{"_id":"4"}}

{"index":{"_id":"3"}}
{"name": "Create or Update - New Jane Doe" }

{"create":{"_id":"4"}}
{"name": "Only Create - New Jane Doe" }

{"create":{"_id":"5"}}
{"name": "Only Create - New Jane Doe 1" }'

The Response Contains just 4 Outputs instead of 5 :

{
  "took": 100,
  "errors": false,
  "items": [
    {
      "update": {
        "_index": "customer",
        "_type": "external",
        "_id": "1",
        "_version": 9,
        "result": "noop",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "status": 200
      }
    },
    {
      "delete": {
        "found": true,
        "_index": "customer",
        "_type": "external",
        "_id": "4",
        "_version": 4,
        "result": "deleted",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "status": 200
      }
    },
    {
      "index": {
        "_index": "customer",
        "_type": "external",
        "_id": "3",
        "_version": 7,
        "result": "updated",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "created": false,
        "status": 200
      }
    },
    {
      "create": {
        "_index": "customer",
        "_type": "external",
        "_id": "4",
        "_version": 5,
        "result": "created",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "created": true,
        "status": 201
      }
    }
  ]
}

In my scenario, the customer with id "5" (name: "Only Create - New Jane Doe 1") was never created. If I remove this last request (id:5) then even id:4 is not getting created.

I did a search to get all documents for customer index, but id:5 was not present.

Its as if Elastic search is ignoring the last part of JSON. I even tried to post the request through PostmanClient and its still the same.

Elastic Search Version : 5.1.1

You need a \n after every action, even the last - https://www.elastic.co/guide/en/elasticsearch/reference/5.1/docs-bulk.html

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.