# NEST 7.9 Bulk Partial Update failing

**URL:** https://discuss.elastic.co/t/nest-7-9-bulk-partial-update-failing/250581
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [October 1, 2020, 1:48am UTC](https://discuss.elastic.co/t/nest-7-9-bulk-partial-update-failing/250581 "2020-10-01T01:48:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![venkatsvr4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkatsvr4/32/76489_2.png) [@venkatsvr4](https://discuss.elastic.co/u/venkatsvr4)
#### Post date: [October 1, 2020, 1:49am UTC](https://discuss.elastic.co/t/nest-7-9-bulk-partial-update-failing/250581/1 "2020-10-01T01:49:00Z")

</div>

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#

> [@Please explain how to perform a bulk update with partials using UpdateMany](https://discuss.elastic.co/t/please-explain-how-to-perform-a-bulk-update-with-partials-using-updatemany/183873):
>
> I am really surprised by the lack of documentation for the NEST client. I am using NEST 6.6.0. I have an array of partial documents (anonymous objects) -- each includes an id field and the fields that I want to update. Please show me an example of how to do this. I've seen an example where the you have to pass an IEnumerable\< T \> instead of IEnumerable\< TPartial \>, but that doesn't make sense. I have a bunch of partial documents that include the ids already. Is there a way to do this?

```auto
     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

```auto
# 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?

---

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [October 19, 2020, 2:09am UTC](https://discuss.elastic.co/t/nest-7-9-bulk-partial-update-failing/250581/3 "2020-10-19T02:09:11Z")

</div>

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`

```auto
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.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [November 16, 2020, 2:09am UTC](https://discuss.elastic.co/t/nest-7-9-bulk-partial-update-failing/250581/4 "2020-11-16T02:09:16Z")

</div>

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