# Importing JSON in to Elasticsearch 5.1 using CURL

**URL:** <https://discuss.elastic.co/t/importing-json-in-to-elasticsearch-5-1-using-curl/74452>\
**Category:** Elasticsearch\
**Created:** [February 9, 2017, 12:28am UTC](https://discuss.elastic.co/t/importing-json-in-to-elasticsearch-5-1-using-curl/74452 "2017-02-09T00:28:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gjws](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@gjws](https://discuss.elastic.co/u/gjws)\
**Post date:** [February 9, 2017, 12:28am UTC](https://discuss.elastic.co/t/importing-json-in-to-elasticsearch-5-1-using-curl/74452/1 "2017-02-09T00:28:00Z")

</div>

I'm trying to import a large JSON document in to Elasticsearch 5.1. A small section of the data looks like this:

> [  
> {  
> "id": 1,  
> "region": "ca-central-1",  
> "eventName": "CreateRole",  
> "eventTime": "2016-02-04T03:41:19.000Z",  
> "userName": "[email@group.com](mailto:email@group.com)"  
> },  
> {  
> "id": 2,  
> "region": "ca-central-1",  
> "eventName": "AddRoleToInstanceProfile",  
> "eventTime": "2016-02-04T03:41:19.000Z",  
> "userName": "[email@group.com](mailto:email@group.com)"  
> },  
> {  
> "id": 3,  
> "region": "ca-central-1",  
> "eventName": "CreateInstanceProfile",  
> "eventTime": "2016-02-04T03:41:19.000Z",  
> "userName": "[email@group.com](mailto:email@group.com)"  
> },  
> {  
> "id": 4,  
> "region": "ca-central-1",  
> "eventName": "AttachGroupPolicy",  
> "eventTime": "2016-02-04T01:42:36.000Z",  
> "userName": "[email@group.com](mailto:email@group.com)"  
> },  
> {  
> "id": 5,  
> "region": "ca-central-1",  
> "eventName": "AttachGroupPolicy",  
> "eventTime": "2016-02-04T01:39:20.000Z",  
> "userName": "[email@group.com](mailto:email@group.com)"  
> }  
> ]

I'd like to import the data without making any changes to the source data if possible, so I believe that rules out the \_bulk command as I'd need to add additional details for each entry.

I've tried several different methods but have not had any luck. Am I wasting my time trying to import this document as-is?

I've tried:

> curl -XPOST '[demo.ap-southeast-2.es.amazonaws.com/rea/test](http://demo.ap-southeast-2.es.amazonaws.com/rea/test)' --data-binary @Records.json

But that fails with an error:

> {"error":{"root\_cause":[{"type":"mapper\_parsing\_exception","reason":"failed to parse"}],"type":"mapper\_parsing\_exception","reason":"failed to parse","caused\_by":{"type":"not\_x\_content\_exception","reason":"Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes"}},"status":400}

Thanks!

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 9, 2017, 3:45am UTC](https://discuss.elastic.co/t/importing-json-in-to-elasticsearch-5-1-using-curl/74452/2 "2017-02-09T03:45:37Z")

</div>

You want to index individual events or only all events?

I believe the former.

I'd use logstash to split it into individual records.

You can't index such a document directly as it does not start with {.

---

<div class="post-metadata">

**Author:** ![gjws](https://avatars.discourse-cdn.com/v4/letter/g/74df32/32.png) [@gjws](https://discuss.elastic.co/u/gjws)\
**Post date:** [February 9, 2017, 4:02am UTC](https://discuss.elastic.co/t/importing-json-in-to-elasticsearch-5-1-using-curl/74452/3 "2017-02-09T04:02:56Z")

</div>

Thanks dadoonet.

I'm using AWS ES, and REALLY want to avoid spinning up LS if I can help it.

I could add the entire array in to curly braces { data: ....

But I'm guessing that will lead to it being treated as a single event, if I'm reading your reply correctly?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 9, 2017, 6:22am UTC](https://discuss.elastic.co/t/importing-json-in-to-elasticsearch-5-1-using-curl/74452/4 "2017-02-09T06:22:17Z")

</div>

Yes. It will.

---

<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 9, 2017, 6:22am UTC](https://discuss.elastic.co/t/importing-json-in-to-elasticsearch-5-1-using-curl/74452/5 "2017-03-09T06:22:18Z")

</div>

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