# Using new elasticsearch client 8.0.8, creating a index , add a record and update the existing record

**URL:** https://discuss.elastic.co/t/using-new-elasticsearch-client-8-0-8-creating-a-index-add-a-record-and-update-the-existing-record/328522
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [March 25, 2023, 3:36pm UTC](https://discuss.elastic.co/t/using-new-elasticsearch-client-8-0-8-creating-a-index-add-a-record-and-update-the-existing-record/328522 "2023-03-25T15:36:52Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sudhakarvaradharaj](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@sudhakarvaradharaj](https://discuss.elastic.co/u/sudhakarvaradharaj)
#### Post date: [March 25, 2023, 3:36pm UTC](https://discuss.elastic.co/t/using-new-elasticsearch-client-8-0-8-creating-a-index-add-a-record-and-update-the-existing-record/328522/1 "2023-03-25T15:36:52Z")

</div>

I am using client 8.0.8 Elastic.Clients.Elasticsearch to create index, add a record and update the existing record to the index.

What is the appropriate method to add and update the index.

Here is the code snippet I used to add and update, but the below snippet always add a record.

```
     var response = elasticsearchClient.BulkAll(overpaymentSearchData,
            b => b.Index(ConfigIndexKeys.OverpaymentIndex)
            .BackOffTime("30s")
            .BackOffRetries(3)
            .RefreshOnCompleted()
            .MaxDegreeOfParallelism(10)
            .Size(500))
            .Wait(TimeSpan.FromMinutes(5), next =>
            { }
            );

```

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [March 26, 2023, 7:46am UTC](https://discuss.elastic.co/t/using-new-elasticsearch-client-8-0-8-creating-a-index-add-a-record-and-update-the-existing-record/328522/2 "2023-03-26T07:46:03Z")

</div>

I do not use this client, but it does not seem like you are specifying a document ID. This is how Elasticsearch identifies a document and if you do not specify it, a new document with an ID generated by Elasticsearch will always be generated.

---

<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: [April 23, 2023, 7:46am UTC](https://discuss.elastic.co/t/using-new-elasticsearch-client-8-0-8-creating-a-index-add-a-record-and-update-the-existing-record/328522/3 "2023-04-23T07:46:14Z")

</div>

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