NEST 7.9 Bulk Partial Update failing

I am using Nest 7.9 client to bulk update documents in a huge index. Followed below 6.6 link to set up updates in C#

     List<JObject> jiras = new List<JObject>();
                    JObject id1 = new JObject();
                    id1.Add("id", "vlHNQnEBb8EcauKoEC0r");id1.Add("_type", "_doc");id1.Add("issue", "VIPENG - 37376");
                    JObject id2 = new JObject();
                    id2.Add("id", "lHFQnEBb8EcauKowyzQ");
                    id2.Add("_type", "_doc");
                    jiras.Add(id1); jiras.Add(id2);
                    var bulkResponse = client.Bulk(b => b
                    .Index("issue_updated")
                    .UpdateMany(jiras.ToArray(), (bu, d) => bu.Doc(d)));

Not able to set id,type for documents as shown below

# Invalid Bulk items:
# Audit trail of this API call:
 - [1] BadResponse: Node: https://elasticscm-dev.com/ Took: 00:00:01.1550475
# OriginalException: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /issue_updated/_bulk. ServerError: Type: action_request_validation_exception Reason: "Validation Failed: 1: type is missing;2: id is missing;3: type is missing;4: id is missing;"
# Request:
{"update":{"_id":null}}
{"doc":{"id":"vlHNQnEBb8EcauKoEC0r","_type":"_doc","issue":"VIPENG - 37376"}}
{"update":{"_id":null}}
{"doc":{"id":"lHFQnEBb8EcauKowyzQ","_type":"_doc"}}

Can someone please let me know how to set id and type of bulk documents?

Assuming you're also using JsonNetSerializer, the .Id() should also be set in the UpdateMany() call, since NEST has no way of inferring an Id property from an instance of JObject

List<JObject> jiras = new List<JObject>();
JObject id1 = new JObject();
id1.Add("id", "vlHNQnEBb8EcauKoEC0r"); id1.Add("_type", "_doc"); id1.Add("issue", "VIPENG - 37376");
JObject id2 = new JObject();
id2.Add("id", "lHFQnEBb8EcauKowyzQ");
id2.Add("_type", "_doc");
jiras.Add(id1); jiras.Add(id2);

var bulkResponse = client.Bulk(b => b
	.Index("issue_updated")
	.UpdateMany(jiras, (bu, d) => bu.Doc(d).Id(d["id"].Value<string>()))
);

NEST 7.9 does not expose setting a document type, and "_doc" is the value automatically used by Elasticsearch 7.x, so no need to set it.

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