Elasticsearch NEST API handle failed bulk updates

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,
Script Query send from dotNet application is given below

Sample code:

POST _bulk
      "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.

Any updates on the above question ?

Please can you edit your question to

  • indicate what version of NEST you're using
  • indicate what version of Elasticsearch you're targeting
  • show the call you're making with NEST
  • how you're handling the response, and what you're not able to get on it

With this information, it should be possible to understand what the issue is.

This doesn't include the result parameter to get noop response

public interface IBulkResponseItem
// Summary:
// The type of bulk operation
string Operation { get; }
// Summary:
// The index against which the bulk operation ran
string Index { get; }
// Summary:
// The type against which the bulk operation ran
string Type { get; }
// Summary:
// The id of the document for the bulk operation
string Id { get; }
// Summary:
// The version of the document
long Version { get; }
// Summary:
// The status of the bulk operation
int Status { get; }
// Summary:
// The error associated with the bulk operation
BulkError Error { get; }
// Summary:
// The shards associated with the bulk operation
ShardStatistics Shards { get; }
long SequenceNumber { get; }
long PrimaryTerm { get; }
// Summary:
// Specifies wheter this particular bulk operation succeeded or not
bool IsValid { get; }

Thanks, I've opened an issue to address for the next release.

Is it a best practice to use ```

else{ Debug.explain(ctx._source); ctx.op = 'none'; }}.

To get 404 exception and handle the noop scenario as an interim solution ?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.