How to get report of before and after +/-5 lines of log when message match = my-error to my email in x-pack in elasticsearch

PUT _xpack/watcher/watch/log_error_watch
{
"trigger" : { "schedule" : { "interval" : "10s" }},
"input" : {
"search" : {
"request" : {
"indices" : [ "filebeat-*" ],
"body" : {
"query" : {
"bool" : {
"must" : [
{ "match" : { "message": "error" }},
{ "range" : { "result.execution_time" : { "from" : "now-10s" }}}
]
}
}
}
}
}
},
"condition" : {
"compare" : { "ctx.payload.hits.total" : { "gt" : 0 }}
},
"actions" : {
"email_admin" : {
"email": {
"to": "John Doe john.doe@example.com",
"subject" : "Error Warning from Watcher",
"body": "{{ctx.payload.hits.total}} errors JBOSS Error Logs. They are {{ctx.payload.hits.hits.0._source.host}} {{ctx.payload.hits.hits.0._source.message}} {{ctx.payload.hits.hits.1._source.message}} {{ctx.payload.hits.hits.2._source.message}} "

}
}
}

Here I want to get before and after +/-5 lines and host.name only when the message matches error in email using x-pack in elasticsearch in the form of plain text format. Please, anyone, help me here.

It's easier to assist you if you don't open multiple topics on the same question. Let's continue the discussion in your existing topic How to get report of before and after 5 lines of log when message match = my-error to my email in x-pack in elasticsearch in plain text format