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: 6
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 ?
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
[JsonPropertyAttribute("_index")]
string Index { get; }
//
// Summary:
// The type against which the bulk operation ran
[JsonPropertyAttribute("_type")]
string Type { get; }
//
// Summary:
// The id of the document for the bulk operation
[JsonPropertyAttribute("_id")]
string Id { get; }
//
// Summary:
// The version of the document
[JsonPropertyAttribute("_version")]
long Version { get; }
//
// Summary:
// The status of the bulk operation
[JsonPropertyAttribute("status")]
int Status { get; }
//
// Summary:
// The error associated with the bulk operation
[JsonPropertyAttribute("error")]
BulkError Error { get; }
//
// Summary:
// The shards associated with the bulk operation
[JsonPropertyAttribute("_shards")]
ShardStatistics Shards { get; }
[JsonPropertyAttribute("_seq_no")]
long SequenceNumber { get; }
[JsonPropertyAttribute("_primary_term")]
long PrimaryTerm { get; }
//
// Summary:
// Specifies wheter this particular bulk operation succeeded or not
bool IsValid { get; }
}
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.