# Highlighting Creates Incorrect JSON Format for Response

**URL:** <https://discuss.elastic.co/t/highlighting-creates-incorrect-json-format-for-response/24652>\
**Category:** Elasticsearch\
**Created:** [June 30, 2015, 5:48pm UTC](https://discuss.elastic.co/t/highlighting-creates-incorrect-json-format-for-response/24652 "2015-06-30T17:48:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SkylerZ](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@SkylerZ](https://discuss.elastic.co/u/SkylerZ)\
**Post date:** [June 30, 2015, 5:48pm UTC](https://discuss.elastic.co/t/highlighting-creates-incorrect-json-format-for-response/24652/1 "2015-06-30T17:48:19Z")

</div>

Hello,

Using Elasticsearch 1.6.0 and am getting some weird behavior from highlighting. When I add highlighting to my queries, all responses have an extra comma (",") between the "\_source" and the "highlight" return fields, except for those that are pretty printed to the command line (pretty printing to a file also causes the double comma). The data I am currently searching over is confidential so I cannot show an exact example of the output, but it is in essence the following:

```
{"_index":"index","_type":"type","_id":"id","_score":"2","_source":{...source text...LASTFIELD:LASTVALUE},
,"highlight" : {"FIELDHIGHLIGHTED" :"..."}},next_document

```

The "highlight" field is always on the next line from the document it is related to, with a comma at the end of the document's line and at the beginning of the highlight's line.

Any ideas what might be going on? Thanks!

Skyler

---

<div class="post-metadata">

**Author:** ![SkylerZ](https://avatars.discourse-cdn.com/v4/letter/s/b9e5f3/32.png) [@SkylerZ](https://discuss.elastic.co/u/SkylerZ)\
**Post date:** [June 30, 2015, 9:05pm UTC](https://discuss.elastic.co/t/highlighting-creates-incorrect-json-format-for-response/24652/2 "2015-06-30T21:05:06Z")

</div>

Issue resolved, it was from some improperly formatted documents I had indexed.

Never, ever, ever try to index anything that ends in a comma. They will index and search fine, but the "\_source" field will contain a trailing comma which can mess up a ton of JSON parsing.

---

<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 6, 2017, 12:04am UTC](https://discuss.elastic.co/t/highlighting-creates-incorrect-json-format-for-response/24652/3 "2017-07-06T00:04:27Z")

</div>

Closed on July 6, 2017, 12:04am UTC


