Does the script in the "reindex API" support mapping of nested fields to non nested fields?
If i do use the script I keep getting cannot create source field in dest index, even though I have "remove".
What is the issue?
Error on reindex mapping
Source Mapping
PUT /share_old1
{
"aliases": {
"share_old": {}
},
"mappings": {
"dynamic": "strict",
"properties": {
"@timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||strict_date_optional_time||epoch_millis"
},
"field1": {
"type": "integer"
},
"field2": {
"type": "keyword",
"normalizer": "lowercase"
},
"field3": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||strict_date_optional_time||epoch_millis"
},
"outer": {
"type": "nested",
"properties": {
"classification": {
"type": "keyword"
},
"inner": {
"properties": {
"innerType": {
"properties": {
"fields": {
"type": "nested",
"properties": {
"key": {
"type": "keyword",
"normalizer": "lowercase"
},
"value": {
"type": "text"
}
}
},
"name": {
"type": "keyword",
"normalizer": "lowercase"
},
"number": {
"type": "keyword"
},
"type": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
}
Dest Mapping
PUT /share_new1
{
"aliases": {
"share_new": {}
},
"mappings": {
"dynamic": "strict",
"properties": {
"@timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||strict_date_optional_time||epoch_millis"
},
"field1": {
"type": "integer"
},
"field2": {
"type": "keyword",
"normalizer": "lowercase"
},
"field3": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||strict_date_optional_time||epoch_millis"
},
"inner": {
"properties": {
"innerType": {
"properties": {
"fields": {
"type": "nested",
"properties": {
"key": {
"type": "keyword",
"normalizer": "lowercase"
},
"value": {
"type": "text"
}
}
},
"name": {
"type": "keyword",
"normalizer": "lowercase"
},
"number": {
"type": "keyword"
},
"type": {
"type": "keyword"
}
}
}
}
}
}
}
}
Reindex request:
POST _reindex?pretty
{
"source": {
"index": "share_old1"
},
"dest": {
"index": "share_new1"
},
"conflicts": "proceed",
"script": {
"source": "ctx._source.inner = ctx._source.remove(\"outer[0].inner\")"
}
}
ERROR
{
"took" : 656,
"timed_out" : false,
"total" : 1,
"updated" : 0,
"created" : 0,
"deleted" : 0,
"batches" : 1,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until_millis" : 0,
"failures" : [
{
"index" : "data1",
"type" : "_doc",
"id" : "2",
"cause" : {
"type" : "strict_dynamic_mapping_exception",
"reason" : "mapping set to strict, dynamic introduction of [outer] within [_doc] is not allowed"
},
"status" : 400
}
]
}