# Where is the exception in “json\_parse\_exception”?

**URL:** <https://discuss.elastic.co/t/where-is-the-exception-in-json-parse-exception/175845>\
**Category:** Elasticsearch\
**Created:** [April 8, 2019, 1:09pm UTC](https://discuss.elastic.co/t/where-is-the-exception-in-json-parse-exception/175845 "2019-04-08T13:09:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronyarmon](https://avatars.discourse-cdn.com/v4/letter/r/b782af/32.png) [@ronyarmon](https://discuss.elastic.co/u/ronyarmon)\
**Post date:** [April 8, 2019, 1:09pm UTC](https://discuss.elastic.co/t/where-is-the-exception-in-json-parse-exception/175845/1 "2019-04-08T13:09:27Z")

</div>

I'm using Kibana/ES 6.5 to index around 470 documents crawled from a Hebrew website with:  
POST /index\_name/\_doc/\_bulk

I can post/get few individual documents but some probably carry some illegal characters as when I'm posting all I'm getting the following error message:

> {  
> "error": {  
> "root\_cause": [  
> {  
> "type": "json\_parse\_exception",  
> "reason": "Unexpected character ('×' (code 215)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@138e10d; line: 1, column: 2]"  
> }  
> ],  
> "type": "json\_parse\_exception",  
> "reason": "Unexpected character ('×' (code 215)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: org.elasticsearch.transport.netty4.ByteBufStreamInput@138e10d; line: 1, column: 2]"  
> },  
> "status": 500  
> }

Is there a way to find out which of the documents contain the characters that have led to this error?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [April 15, 2019, 9:26am UTC](https://discuss.elastic.co/t/where-is-the-exception-in-json-parse-exception/175845/2 "2019-04-15T09:26:23Z")

</div>

The responses from a bulk request [come back in the same order as the request](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html):

> The response to a bulk action is a large JSON structure with the individual results of each action that was performed in the same order as the actions that appeared in the request. The failure of a single action does not affect the remaining actions.

Thus if this error appears in the 4th entry of the `items` array in the response then it's the 4th document that has a problem.

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [April 15, 2019, 9:31am UTC](https://discuss.elastic.co/t/where-is-the-exception-in-json-parse-exception/175845/3 "2019-04-15T09:31:28Z")

</div>

> [@ronyarmon](#):
>
> "status": 500

Sorry, I just saw this. I think this indicates that the whole request was malformed, rather than any individual document. You must alternate lines like this:

```auto
action_and_meta_data\n
optional_source\n
action_and_meta_data\n
optional_source\n
....
action_and_meta_data\n
optional_source\n

```

Perhaps there is a newline embedded in one or more of your documents?

---

<div class="post-metadata">

**Author:** ![ronyarmon](https://avatars.discourse-cdn.com/v4/letter/r/b782af/32.png) [@ronyarmon](https://discuss.elastic.co/u/ronyarmon)\
**Post date:** [April 18, 2019, 12:00pm UTC](https://discuss.elastic.co/t/where-is-the-exception-in-json-parse-exception/175845/4 "2019-04-18T12:00:37Z")

</div>

Thanks. I've cleaned the documents of newlines so the only option is to search for it manually which is what I wanted to avoid. Regarding your first answer, I don't see any entry of items in the response, only line/column reference.

---

<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:** [May 16, 2019, 12:00pm UTC](https://discuss.elastic.co/t/where-is-the-exception-in-json-parse-exception/175845/5 "2019-05-16T12:00:40Z")

</div>

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