Hi!
First, sorry for the newb question, however 2h of googling proved i'm either unqualified or explicitly trying to do the task wrong way
I'm trying to reindex with new mappings, however due to field data type change, it's not processing. I've found this simple snippet in the docs:
POST _reindex
{
"source": {
"index": "old-index"
},
"dest": {
"index": "new-index"
},
"script": {
"inline": "if (ctx._source.FIELD_NAME == 'null' ) {ctx._source.FIELD_NAME = '0'}"
}
}
while this seems to work, there documents where the FIELD_NAME value is 'undefined' and I'd like to catch that as well, together with 'null' in the same request. I've tried writing simple || FIELD_NAME if, however apparently it is not the proper way to do so.
So, how do I properly change both 'null' and 'undefined' values from specific field to '0' during reindexing?
Here's a snippet from the error executing this request:
"failures": [
{
"index": "new-index",
"type": "_doc",
"id": "redacted",
"cause": {
"type": "mapper_parsing_exception",
"reason": "failed to parse field [FIELD_NAME] of type [long] in document with id 'redacted'. Preview of field's value: 'undefined'",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "For input string: \"undefined\""
}
},
"status": 400
},
ES/Kibana 7.4 for reference. Thank You very much in advance for any help/tips.