Dealing with a user-defined object in about 600k records and want to reindex to standardized field naming. Issue is field has space in name and I'm struggling to figure syntax in script
to reference old field with space in name to move to field without.
Ideas/suggestions?
Reindex attempt
{
"source": {
"index": "records-test"
},
"dest": {
"index": "records-reindex-20180924"
},
"script": {
"source": "ctx._source.subject.desired_location.point.lat = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lat; ctx._source.subject.desired_location.point.lon = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lon; ctx._source.subject.list.custom_fields.remove('Desired location')"
}
}
Yields the following error:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.subject.desired_location.point.lat = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lat; ",
" ^---- HERE"
],
"script": "ctx._source.subject.desired_location.point.lat = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lat; ctx._source.subject.desired_location.point.lon = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lon; ctx._source.subject.list.custom_fields.remove('Desired location')",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.subject.desired_location.point.lat = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lat; ",
" ^---- HERE"
],
"script": "ctx._source.subject.desired_location.point.lat = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lat; ctx._source.subject.desired_location.point.lon = ctx._source.subject.list.custom_fields['Desired location'].value.location.point.lon; ctx._source.subject.list.custom_fields.remove('Desired location')",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null
}
},
"status": 500
}
Updated with new attempt and related error
Even trying to simplify to copy point field to point field fails with NPE
POST /_reindex
{
"source": {
"index": "records-test"
},
"dest": {
"index": "records-reindex-20180924"
},
"script": {
"source": "ctx._source.subject.desired_location.point = ctx._source.subject.list.custom_fields['Desired location'].value.location.point; ctx._source.subject.list.custom_fields.remove('Desired location')"
}
}
Yields:
{
"error": {
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.subject.desired_location.point = ctx._source.subject.list.custom_fields['Desired location'].value.location.point; ",
" ^---- HERE"
],
"script": "ctx._source.subject.desired_location.point = ctx._source.subject.list.custom_fields['Desired location'].value.location.point; ctx._source.subject.list.custom_fields.remove('Desired location')",
"lang": "painless"
}
],
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"ctx._source.subject.desired_location.point = ctx._source.subject.list.custom_fields['Desired location'].value.location.point; ",
" ^---- HERE"
],
"script": "ctx._source.subject.desired_location.point = ctx._source.subject.list.custom_fields['Desired location'].value.location.point; ctx._source.subject.list.custom_fields.remove('Desired location')",
"lang": "painless",
"caused_by": {
"type": "null_pointer_exception",
"reason": null
}
},
"status": 500
}