Field type has changed automatically and dynamically after millions of indexed


(Maziyar Panahi) #1

Hi,

I have an index_template that says the field "article" should be type string. And it started with string with over 5 million documents indexed. So the existing data are mapped with string which it is impossible to be changed. (so as everyone always asking this question)

But this morning the mapping has changed to an array! I have 5 million documents with string and new ones are coming as an array of one string. My mapping still shows the type is string:
(all of the documents are in the same index)

"article": {
"type": "string"
},

So how is this possible to have one field in a schema with two different mapping types and how this happened dynamically?

Here is some detail:

Elasticsearch: 2.1

template:

{
"order": 0,
"template": "climate-",
"settings": {
"index": {
"number_of_shards": "4",
"number_of_replicas": "0"
}
},
"mappings": {
"tweet": {
"dynamic_templates": [
{
"string_fields": {
"mapping": {
"index": "analyzed",
"omit_norms": true,
"type": "string",
"fields": {
"raw": {
"ignore_above": 256,
"index": "not_analyzed",
"type": "string"
}
}
},
"match_mapping_type": "string",
"match": "
"
}
}
],
"_all": {
"enabled": false
},
"properties": {
"tx": {
"type": "string"
},
"coordinates": {
"properties": {
"coordinates": {
"type": "geo_point"
},
"type": {
"type": "string"
}
}
},
"article": {
"type": "string"
},
"ca": {
"format": "dateOptionalTime",
"type": "date"
}
}
}
},
"aliases": {}
}

There might be something wrong with my template, but how is it possible to be changed after the first initiation. This directly effected my search queries and that's how I found out despite the mapping shows string I am indexing array like this:

"article": [
    "The onset...."
]

GET climate/_mapping/field/article

{
"climate": {
"mappings": {
"doc": {
"article": {
"full_name": "article",
"mapping": {
"article": {
"type": "string"
}
}
}
}
}
}
}

Many thanks
Maziyar

{
"climate": {
"mappings": {
"doc": {
"article": {
"full_name": "article",
"mapping": {
"article": {
"type": "string"
}
}
}
}
}
}
}

Many thanks
Maziyar


(system) #2