Hi,
I'm looking to copy data from one field to another, if initially the destination field is blank assign a value, if non blank don't overwrite to another but upon re-indexing from another source the doc pipeline doesn't seem to work as the destination fields are blank post the run of pipeline but when manually updated the code does work.
PUT _ingest/pipeline/auto_now_add_new
{
"processors": [
{
"script": {
"source": """
if (ctx['bkp_email'] != null) { return; }
ctx['bkp_email'] = ctx['email'];
"""
}
},
{
"script": {
"source": """
// don't overwrite if present
if (ctx['bkp_phone'] != null) { return; }
ctx['bkp_phone'] = ctx['phone'];
"""
}
}
]
}
Not sure if I'm missing something,
Appreciate your input's
Thanks,