# Mapping gets messed up in result of indexing a Json document

**URL:** <https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253>\
**Category:** Elasticsearch\
**Created:** [March 23, 2016, 4:29pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253 "2016-03-23T16:29:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![flx](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@flx](https://discuss.elastic.co/u/flx)\
**Post date:** [March 23, 2016, 4:29pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253/1 "2016-03-23T16:29:49Z")

</div>

I have an index that is supposed to store a Json object. As a result of doing so my mapping somehow gets messed up. This is the mapping I created before indexing any documents:

```
{
    "json": {
	"type": "object"
    }
}

```

This is the document I'd like to index:

```
{
    "json": {
	"read": {
		"/db/Role/1": "allow"
	}
    }
}

```

As a result the mapping changes to this:

```
{
    "json": {
	"properties": {
		"read": {
			"properties": {
				"/db/Role/1": {
					"type": "string"
				}
			}
		}
	}
    }
}

```

I presume I made a stupid mistake that is easy to fix. I just can't figure it out. Hope someone can help.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 23, 2016, 5:08pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253/2 "2016-03-23T17:08:35Z")

</div>

Why do you thing the new mapping is wrong?  
It looks correct to me.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 23, 2016, 5:09pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253/3 "2016-03-23T17:09:25Z")

</div>

May be you don't want to index the inner content but just store it?

---

<div class="post-metadata">

**Author:** ![flx](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@flx](https://discuss.elastic.co/u/flx)\
**Post date:** [March 23, 2016, 5:23pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253/4 "2016-03-23T17:23:41Z")

</div>

I am fairly new to Elasticsearch and was wondering why it stores part of the content of my Json document in the mapping. It just looked off to me. Based on your answer I assume it stores the structure of the document in the mapping to make single fields searchable, not just the whole document. Then I never had a problem to begin with but simply misunderstood what was happening. 🙂

Out of curiosity: What would I have to do to just store the document without indexing?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 23, 2016, 5:51pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253/5 "2016-03-23T17:51:22Z")

</div>

`"enabled": false`. See [https://www.elastic.co/guide/en/elasticsearch/reference/2.2/object.html#object-params](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/object.html#object-params)

---

<div class="post-metadata">

**Author:** ![flx](https://avatars.discourse-cdn.com/v4/letter/f/a4c791/32.png) [@flx](https://discuss.elastic.co/u/flx)\
**Post date:** [March 23, 2016, 5:58pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253/6 "2016-03-23T17:58:00Z")

</div>

Thanks a lot for your help!

---

<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 5, 2017, 11:05pm UTC](https://discuss.elastic.co/t/mapping-gets-messed-up-in-result-of-indexing-a-json-document/45253/7 "2017-07-05T23:05:45Z")

</div>


