Improve taskId detection in EsOutputFormat

Relates #280

(cherry picked from commit 145ad76e413186c5a2d57c61e2300008e7c847e3)