Hi,
We have the following data stored in our existing index.
{
"id": "83c55df4-dd6d-11ea-87d0-0242ac130003",
"name": "test",
"customData": {
"id_int": 16934,
"year": "2020",
"number": "0001",
"anotherField": "anotherValue",
"anotherField2": "anotherValue2",
},
"testFeild": false,
"regNumbers": [
"cccccc"
],
"types": [
"test"
]
}
We now want to change this data, update the mappings and copying some of the fields into new fields and removing them once done, could something like this be achieved with the Reindex or Update API or would it need some sort of custom written approach? So moving some fields from customData to new fields in customDetails
{
"id": "83c55df4-dd6d-11ea-87d0-0242ac130003",
"name": "test",
"customData": {
"anotherField": "anotherValue",
"anotherField2": "anotherValue2",
},
"customDetails": {
"id_int": 16934,
"year": "2020",
"number": "0001",
},
"testFeild": false,
"regNumbers": [
"cccccc"
],
"types": [
"test"
]
}
I had attempted something with the Reindex API but kept getting a null pointer.
{
"source": {
"index": "dev204113",
"query": {
"match_all" : {}
}
},
"dest": {
"index": "dev204113_test"
},
"script": {
"source": "ctx._source.customData.id_int=ctx._source.customDetails.id_int",
"lang": "painless"
}
}