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

**URL:** <https://discuss.elastic.co/t/elastic-search-bulk-upload-is-ignoring-the-last-operation-provided-in-the-json/70232>\
**Category:** Elasticsearch\
**Created:** [December 29, 2016, 7:20pm UTC](https://discuss.elastic.co/t/elastic-search-bulk-upload-is-ignoring-the-last-operation-provided-in-the-json/70232 "2016-12-29T19:20:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bandikishores](https://avatars.discourse-cdn.com/v4/letter/b/b5a626/32.png) [@bandikishores](https://discuss.elastic.co/u/bandikishores)\
**Post date:** [December 29, 2016, 7:20pm UTC](https://discuss.elastic.co/t/elastic-search-bulk-upload-is-ignoring-the-last-operation-provided-in-the-json/70232/1 "2016-12-29T19:20:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [December 29, 2016, 9:04pm UTC](https://discuss.elastic.co/t/elastic-search-bulk-upload-is-ignoring-the-last-operation-provided-in-the-json/70232/2 "2016-12-29T21:04:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 26, 2017, 9:05pm UTC](https://discuss.elastic.co/t/elastic-search-bulk-upload-is-ignoring-the-last-operation-provided-in-the-json/70232/3 "2017-01-26T21:05:17Z")

</div>

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