Conditionally merge values from 2 fields into 1 new field

I'm looking for a recommended way to copy value either from field1 or field2, whichever is not empty and field2 take precedence over field1, into a third field name field3

I was trying to do that with scripted fields, I'm wondering if there is other options that can be more performing

At this point an ingest pipeline is where I'd look.