Mapping gets messed up in result of indexing a Json document


#1

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.


(David Pilato) #2

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


(David Pilato) #3

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


#4

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?


(David Pilato) #5

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


#6

Thanks a lot for your help!


(system) #7