Dynamic mapping overrides fields?


(philipDS) #1

Hey,

I set a mapping as follows:

curl -XPUT 'http://localhost:9200/my_index/my_type/_mapping' -d '
{
"my_type" : {
contacts: {
properties: {
user: { type: 'String', index: 'not_analyzed' },
source : { type: 'String', index: 'not_analyzed' },
type : { type: 'String', index: 'not_analyzed' },
user_id : { type: 'String', index: 'not_analyzed' },
profile_url : { type: 'String', index: 'not_analyzed' },
first_name : { type: 'String', index: 'not_analyzed' },
last_name : { type: 'String', index: 'not_analyzed' },
headline : { type: 'String', analyzer: 'lowercase_keyword'
},
industry : { type: 'String', index: 'not_analyzed' },
location : { type: 'String', analyzer: 'lowercase_keyword'
},
picture_url : { type: 'String', index: 'not_analyzed' },
twitter : {
"dynamic": false,
properties : {
handle : { type: 'String', index: 'not_analyzed' },
tweet : { type: 'String', index: 'not_analyzed' },
age : { type: 'Date', index: 'not_analyzed' }
}
},
extra_info : {
"dynamic": false,
properties : {
topics : { type: 'String', index: 'not_analyzed' },
age : { type: 'Date', index: 'not_analyzed' }
}
},
skills : { type: 'String', index_name: 'skill', index:
'not_analyzed' },
positions : {
properties : {
company : {
properties: {
industry : { type: 'String', index:
'not_analyzed' },
name : { type: 'String', index:
'not_analyzed' },
type: 'nested'
//type : { type: 'String', index:
'not_analyzed' }
},
type: 'nested'
},
isCurrent : { type: 'boolean' },
startDate : {
properties: {
month: { type: 'long', index:
'not_analyzed' },
year: { type: 'long', index: 'not_analyzed'
}
}
},
summary : { type: 'String', index: 'not_analyzed' },
title : { type: 'String', index: 'not_analyzed' }
},
type: 'nested'
},
tags : { type: 'String', index: 'not_analyzed' },
dismissTime : { type: 'Date' },
dateIndexed : { type: 'Date' }
}
}
}'

Note that I set the twitter and extra_info fields (type object?) to
'dynamic: false'. Then I index a bunch of documents, and my ES console
outputs the following: [Power, Alex] [my_index] update_mapping [my_type]
(dynamic). This is ok I guess, since I didn't disable the dynamic field on
the overall root object. However, when I GET my mapping using a CURL then,
I see the following mapping for twitter and extra_info:

"twitter" : {
"type" : "object",
"dynamic" : "true"
},
"extra_info" : {
"type" : "object",
"dynamic" : "true"
},
...

Is there an explanation for this? How can I disable the dynamic field or
make it 'strict'? I have tried setting the overall object to dynamic: false
too, but this didn't help. Anyone knows why this keeps on happening? Thanks!


(Igor Motov) #2

I don't think your mapping is getting applied. There are several issues
with the mapping command in your email including use of apostrophes,
comments in json and missing "properties" between "my_type" and "contacts".

On Tuesday, July 10, 2012 12:23:51 PM UTC-4, philipDS wrote:

Hey,

I set a mapping as follows:

curl -XPUT 'http://localhost:9200/my_index/my_type/_mapping' -d '
{
"my_type" : {
contacts: {
properties: {
user: { type: 'String', index: 'not_analyzed' },
source : { type: 'String', index: 'not_analyzed' },
type : { type: 'String', index: 'not_analyzed' },
user_id : { type: 'String', index: 'not_analyzed' },
profile_url : { type: 'String', index: 'not_analyzed' },
first_name : { type: 'String', index: 'not_analyzed' },
last_name : { type: 'String', index: 'not_analyzed' },
headline : { type: 'String', analyzer: 'lowercase_keyword'
},
industry : { type: 'String', index: 'not_analyzed' },
location : { type: 'String', analyzer: 'lowercase_keyword'
},
picture_url : { type: 'String', index: 'not_analyzed' },
twitter : {
"dynamic": false,
properties : {
handle : { type: 'String', index: 'not_analyzed' },
tweet : { type: 'String', index: 'not_analyzed' },
age : { type: 'Date', index: 'not_analyzed' }
}
},
extra_info : {
"dynamic": false,
properties : {
topics : { type: 'String', index: 'not_analyzed' },
age : { type: 'Date', index: 'not_analyzed' }
}
},
skills : { type: 'String', index_name: 'skill', index:
'not_analyzed' },
positions : {
properties : {
company : {
properties: {
industry : { type: 'String', index:
'not_analyzed' },
name : { type: 'String', index:
'not_analyzed' },
type: 'nested'
//type : { type: 'String', index:
'not_analyzed' }
},
type: 'nested'
},
isCurrent : { type: 'boolean' },
startDate : {
properties: {
month: { type: 'long', index:
'not_analyzed' },
year: { type: 'long', index:
'not_analyzed' }
}
},
summary : { type: 'String', index: 'not_analyzed'
},
title : { type: 'String', index: 'not_analyzed' }
},
type: 'nested'
},
tags : { type: 'String', index: 'not_analyzed' },
dismissTime : { type: 'Date' },
dateIndexed : { type: 'Date' }
}
}
}'

Note that I set the twitter and extra_info fields (type object?) to
'dynamic: false'. Then I index a bunch of documents, and my ES console
outputs the following: [Power, Alex] [my_index] update_mapping [my_type]
(dynamic). This is ok I guess, since I didn't disable the dynamic field on
the overall root object. However, when I GET my mapping using a CURL then,
I see the following mapping for twitter and extra_info:

"twitter" : {
"type" : "object",
"dynamic" : "true"
},
"extra_info" : {
"type" : "object",
"dynamic" : "true"
},
...

Is there an explanation for this? How can I disable the dynamic field or
make it 'strict'? I have tried setting the overall object to dynamic: false
too, but this didn't help. Anyone knows why this keeps on happening? Thanks!


(system) #3