0

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.

Muthu
  • 217
  • 5
  • 16
  • I'm not sure what you mean by "Trying to get noop response for the failed conditions but not able to get the response in dotNet's NEST bulk update API". Can you show the request you're making with the NEST client, and the response you get? – Russ Cam Aug 18 '18 at 09:51
  • While performing bulk update. I am trying to get the "result":"noop" in the response from dotNet client. "took": 1, "errors": false, "items": [ { "update": { "_index": "test-index", "_type": "_doc", "_id": "123", "_version": 6, "result": "noop", "_shards": { "total": 2, "successful": 2, "failed": 0 }, "status": 200 } } ] But I am getting empty response. – Muthu Aug 18 '18 at 13:10
  • Could you edit your question to add the relevant details - it'll be much easier to see what's up. Could you also add the .NET code that you're using to get the response values, and the version of NEST you're using, and version of Elasticsearch you're targeting. – Russ Cam Aug 19 '18 at 13:27
  • updated the question with necessary details ? – Muthu Aug 20 '18 at 11:23
  • How is the sample code in your question being sent to Elasticsearch with NEST? Please can you show that. The code provided would be invalid for a bulk request, which needs to be newline delimited JSON – Russ Cam Aug 20 '18 at 12:32
  • @Russ Cam. The dotNet interface doesnt have the Result field in defined to get the Result:Noop in the response. InterfaceName : IBulkResponseItem. – Muthu Aug 21 '18 at 07:29

0 Answers0