LF(\n) cannot be included in elasticsearch?


(tanimoto) #1

I executed this query.

POST /dev/items/1230
{
  "item_name" : " this includes LF code
  "
}

error happens and error message is as below.

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "failed to parse [item_name]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "failed to parse [item_name]",
    "caused_by": {
      "type": "json_parse_exception",
      "reason": "Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@2bf9746b; line: 2, column: 29]"
    }
  },
  "status": 400
}

When I escape LF as \n or CR as \r, it's registered as string "\n" or string "\r".
Can elasticsearch not register LF and CR??

ES version : 5.1.1


(Jun Ohtani) #2

You have to escape LF. That is JSON specification.


(tanimoto) #3

When I escape LF as \n, it looks like part of string in the registered field value but string color is a bit different from other part of strings.

means, it is recognized as LF internally??

{
  "_index": "dev",
  "_type": "items",
  "_id": "1230",
  "_version": 27,
  "found": true,
  "_source": {
    "item": "we \r and "     ------ here it is.
  }
}
{
  "_index": "dev",
  "_type": "items",
  "_id": "1230",
  "_version": 27,
  "found": true,
  "_source": {
    "item": "we 
 and "     ------ it is not registered like this?
  }
}

(tanimoto) #4

Never mind my new post above.

Thanks a lot!!


(system) #5

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