Mapping gets messed up in result of indexing a Json document

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.

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

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

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. :slight_smile:

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

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

1 Like

Thanks a lot for your help!