# Store selected JSON field as string

**URL:** <https://discuss.elastic.co/t/store-selected-json-field-as-string/65815>\
**Category:** Elasticsearch\
**Created:** [November 11, 2016, 2:03pm UTC](https://discuss.elastic.co/t/store-selected-json-field-as-string/65815 "2016-11-11T14:03:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars2](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@Lars2](https://discuss.elastic.co/u/Lars2)\
**Post date:** [November 11, 2016, 2:03pm UTC](https://discuss.elastic.co/t/store-selected-json-field-as-string/65815/1 "2016-11-11T14:03:06Z")

</div>

I currently have two database columns which contain JSON as a  
nvarchar(max). I need ElasticSearch to analyze one of them, but ignore  
the other one so it will be stored as a string. Is this possible?

I tried the following mapping for the string-json:

```
"jsontest": {
    "type": "object",
    "enabled" : false
 },

```

And also:

```
"jsontest": {
    "type": "string",
    "index" : "not_analyzed"
 },

```

The first will still give me a JSON tree in elasticsearch. The latter gives a MapperParsingException:failed to parse to string

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [November 11, 2016, 5:57pm UTC](https://discuss.elastic.co/t/store-selected-json-field-as-string/65815/2 "2016-11-11T17:57:23Z")

</div>

As long as you escape embedded double quotes inside the string that's actually a JSON string, you should be able to store that string value. ES will treat it as a string and not try to parse it as JSON.

Mike McCandless

---

<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:** [December 9, 2016, 5:57pm UTC](https://discuss.elastic.co/t/store-selected-json-field-as-string/65815/3 "2016-12-09T17:57:23Z")

</div>

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