Elastic Watcher

Hi Team,

I created below watcher -

PUT _watcher/watch/transaction_status_watch
{
"trigger": {
"schedule": {
"interval": "10s"
}
},
"input": {
"search": {
"request": {
"indices": ["test-transaction"],
"body": {
"query": {
"match": {
"status": "Initiate"
}
}
}
}
}
},
"condition": {
"script": {
"source": "if (ctx.payload.hits.hits.size() > 0) { return true; } else { return false; }",
"lang": "painless"
}
},
"actions": {
"index_payload": {
"transform" : {
"script" : {
"source": "ctx.payload.hits.hits[0]._source.status = 'new_value'; return ctx.payload.hits.hits[0]._source",
"lang": "painless"
}
},
"index": {
"index": "test-transaction",
"doc_id": "{{ctx.payload.hits.hits.0._id}}"
}
},
"log" : {
"logging" : {
"text" : "Found {{ctx.payload.hits.total}} -- {{ctx.payload.hits.hits.0._source.correlationId}} -- {{ctx.payload.hits.hits.0._id}} errors in the logs"
}
}
}
}

But {{ctx.payload.hits.hits.0._id}} is not able to find the value instead of that it is creating new document like below-

{
"_index" : "test-transaction",
"_type" : "_doc",
"_id" : "{{ctx.payload.hits.hits.0._id}}",
"_score" : 1.0,
"_source" : {
"payload" : "data",
"correlationId" : "123",
"status" : "new_value"
}

Please let me know if I am missing something.

Anyone face this issue, really appreciate for your help here.