Need a way to check if field is null

New to elasticsearch.

I'm trying to re-index old data into a new index to push it through an updated ingest pipeline. This includes data that's already been through that pipeline, which i want to add to the new index to combine with older data.

I get this error when trying to re-index that data:
"cannot access method/field [empty] from a null def reference"

the field in question being "message", my pipeline deletes message at the end.

Is there a way in painless to skip or exit the execution of the script if "message" doesn't exist?

Hi @mg77345

Did you try with conditionally run processor?

Try like this: { "if" : "ctx.containsKey('field1')" }

Thanks, i ended up using:
if ctx['field'].empty. That seemed to work.