# Parallel\_bulk record format (update, insert, etc.)

**URL:** <https://discuss.elastic.co/t/parallel-bulk-record-format-update-insert-etc/88933>\
**Category:** Elasticsearch\
**Created:** [June 10, 2017, 9:11pm UTC](https://discuss.elastic.co/t/parallel-bulk-record-format-update-insert-etc/88933 "2017-06-10T21:11:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_Hackworth](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Robert\_Hackworth](https://discuss.elastic.co/u/Robert_Hackworth)\
**Post date:** [June 10, 2017, 9:11pm UTC](https://discuss.elastic.co/t/parallel-bulk-record-format-update-insert-etc/88933/1 "2017-06-10T21:11:55Z")

</div>

Hello,

I have been able to get "helpers.parallel\_bulk" in Python (v3) to insert new json records using the the format below (array of JSON records):  
[{'\_id': 'AVyPTQ2d82rj\_AUAq9dc', '\_type': 'mytype', '\_index': 'myindex-2017.06.10', 'starttime': '2017-06-09T23:59:48.670430Z', 'src': '192.168.0.5', 'sport': 4570, etc ... }  
{'\_id': 'AVyPTQ2d82rj\_AUAq9db', '\_type': 'mytype', '\_index': 'myindex-2017.06.10', 'starttime': '2017-06-09T23:59:48.670430Z', 'src': '192.168.0.10', 'sport': 3463, etc ... }  
{'\_id': 'AVyPTQ2d82rj\_AUAq9da', '\_type': 'mytype', '\_index': 'myindex-2017.06.10', 'starttime': '2017-06-09T23:59:48.670430Z', 'src': '192.168.0.11', 'sport': 4987, etc ... }  
etc.]

The problem is that the format seems quite different than the bulk update documentation. Namely:  
[{"index": {"_id": "AVyKQdW282rj\_AUAqK4_", "\_type": "mytype", "\_index": "myindex-2017.06.09"}}  
{'starttime': '2017-06-09T23:59:48.670430Z', 'src': '192.168.0.11', 'sport': 4987, etc ... }  
{"index": {"\_id": "AVyKRJ1a82rj\_AUAqLGR", "\_type": "mytype", "\_index": "myindex-2017.06.09"}}  
{'starttime': '2017-06-09T23:59:48.670430Z', 'src': '192.168.0.11', 'sport': 4987, etc ... }  
etc.]

The issue is that I want to be able to **_update_** and **_index_** records in the same parallel\_bulk request. What is the correct JSON format that I should be using to distinguish between an index, create, update, and delete for each record?

Thanks!

---

<div class="post-metadata">

**Author:** ![Robert\_Hackworth](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Robert\_Hackworth](https://discuss.elastic.co/u/Robert_Hackworth)\
**Post date:** [June 11, 2017, 12:51pm UTC](https://discuss.elastic.co/t/parallel-bulk-record-format-update-insert-etc/88933/2 "2017-06-11T12:51:33Z")

</div>

For those looking for the answer, I was able to find it. There is a \_op\_type code that needs to be added. ([http://elasticsearch-py.readthedocs.io/en/master/helpers.html](http://elasticsearch-py.readthedocs.io/en/master/helpers.html)). From the documentation index is the default, but it will accept index, create, update, detete, etc.

Here is what the record needs to look like:  
{'\_id': 'AVyUdVY882rj\_AUAr36V', '\_type': 'mytype', '\_index': 'myindex-2017.06.11', '\_op\_type': 'update', 'doc': {'fieldtoupdate': 'newvalue'}} [Note: op type, id, type, and index are missing required underscores on the post because the site removes them]

---

<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:** [July 9, 2017, 12:51pm UTC](https://discuss.elastic.co/t/parallel-bulk-record-format-update-insert-etc/88933/3 "2017-07-09T12:51:43Z")

</div>

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