# LF(\\n) cannot be included in elasticsearch?

**URL:** <https://discuss.elastic.co/t/lf-n-cannot-be-included-in-elasticsearch/71337>\
**Category:** Elasticsearch\
**Created:** [January 12, 2017, 8:24am UTC](https://discuss.elastic.co/t/lf-n-cannot-be-included-in-elasticsearch/71337 "2017-01-12T08:24:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [January 12, 2017, 8:24am UTC](https://discuss.elastic.co/t/lf-n-cannot-be-included-in-elasticsearch/71337/1 "2017-01-12T08:24:54Z")

</div>

I executed this query.

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

```

error happens and error message is as below.

```auto
{
  "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

---

<div class="post-metadata">

**Author:** ![johtani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johtani/32/44956_2.png) [@johtani](https://discuss.elastic.co/u/johtani)\
**Post date:** [January 12, 2017, 9:14am UTC](https://discuss.elastic.co/t/lf-n-cannot-be-included-in-elasticsearch/71337/2 "2017-01-12T09:14:40Z")

</div>

You have to escape LF. That is[JSON specification.](https://tools.ietf.org/html/rfc7159#section-7)

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [January 12, 2017, 9:26am UTC](https://discuss.elastic.co/t/lf-n-cannot-be-included-in-elasticsearch/71337/3 "2017-01-12T09:26:05Z")

</div>

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??

```auto
{
  "_index": "dev",
  "_type": "items",
  "_id": "1230",
  "_version": 27,
  "found": true,
  "_source": {
    "item": "we \r and " ------ here it is.
  }
}

```

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

```

---

<div class="post-metadata">

**Author:** ![tanimoto](https://avatars.discourse-cdn.com/v4/letter/t/dec6dc/32.png) [@tanimoto](https://discuss.elastic.co/u/tanimoto)\
**Post date:** [January 12, 2017, 9:40am UTC](https://discuss.elastic.co/t/lf-n-cannot-be-included-in-elasticsearch/71337/4 "2017-01-12T09:40:32Z")

</div>

Never mind my new post above.

Thanks a lot!!

---

<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:** [February 9, 2017, 9:40am UTC](https://discuss.elastic.co/t/lf-n-cannot-be-included-in-elasticsearch/71337/5 "2017-02-09T09:40:47Z")

</div>

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