Updating a nested document using painless script. The document will be updated only when the condition is met. Trying to get noop response for the failed conditions but not able to get the response in dotNet's NEST bulk update API. How to achieve this ?
Elasticsearch version: 6.2.4, NEST version: 6 Response :[ ]. Getting the actual response while running the query from sense plugin Script Query send from dotNet application is given below
Sample code:
POST _bulk
{
"update":{
"_index":"test-index",
"_type":"doc",
"_id":456,
"routing":123
}
}{
"script":{
"params":{
"userStatus":"Approved",
"users":{
"uId":6,
"name":"Test"
}
},
"source":" def found = false; for(i in ctx._source.users){ if (i.uId == 6) { i.userStatus = params.userStatus ;}else{ctx.op = 'none'}}"
}
}
There is another option where we can throw exception's. Is this the right approach to use ?
else{ Debug.explain(ctx._source); ctx.op = 'none'; }}.
Please advice.