# Use \_bulk to import json db

**URL:** <https://discuss.elastic.co/t/use-bulk-to-import-json-db/121240>\
**Category:** Elasticsearch\
**Created:** [February 23, 2018, 3:26pm UTC](https://discuss.elastic.co/t/use-bulk-to-import-json-db/121240 "2018-02-23T15:26:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pereyrdi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pereyrdi/32/12480_2.png) [@pereyrdi](https://discuss.elastic.co/u/pereyrdi)\
**Post date:** [February 23, 2018, 3:26pm UTC](https://discuss.elastic.co/t/use-bulk-to-import-json-db/121240/1 "2018-02-23T15:26:32Z")

</div>

Hello!  
Im migratin ES from version 2 to version 6.2, and I did backups of all index with elasticdump, it create a json with this format.

{"\_index":"conn-scripts-dns","\_type":"devices","\_id":"201711281431118946304","\_score":1,"\_source":{"@timestamp":"2017-11-28T14:31:01-0300","host":"sarha","modelname":"  
dns-ns1","server":"10.30.10.30","time":"0.019"}}  
{"\_index":"conn-scripts-dns","\_type":"devices","\_id":"201711281431220209432","\_score":1,"\_source":{"@timestamp":"2017-11-28T14:31:01-0300","host":"auth","modelname":"dns-  
ns1","server":"10.30.10.30","time":"0.025"}}

is posible run a bulk POST with this json format ?

I try:  
`curl -H 'Content-Type:application/json' -XPUT 'http://localhost:9200/_bulk' -d '{"_index":"conn-scripts-dns","_type":"devices","_id":"201711281431118946304","_score":1,"_source" {"@timestamp":"2017-11-28T14:31:01-0300","host":"sarha","modelname":"dns-ns1","server":"10.30.10.30","time":"0.019"}}'`

but I got this error:  
`{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_STRING]"},"status":400}`

I have many GB in json to import.. please help.  
thanks.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 23, 2018, 4:02pm UTC](https://discuss.elastic.co/t/use-bulk-to-import-json-db/121240/2 "2018-02-23T16:02:18Z")

</div>

Even though it seems to have all the information required, it is not in the format the [bulk API requires](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-bulk.html), so you probably need to create a script to transform it into the correct format before ingesting it. You could probably also get Logstash to parse the lines and use a few filters to perform the required transformation.

---

<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:** [March 23, 2018, 4:02pm UTC](https://discuss.elastic.co/t/use-bulk-to-import-json-db/121240/3 "2018-03-23T16:02:21Z")

</div>

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