Highlighting Creates Incorrect JSON Format for Response


(Skyler Williams) #1

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


(Skyler Williams) #2

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.


(system) #3