Search code examples
c#.netelasticsearchnest

Upsert document with NEST (ElasticSearch)


I'm new to NEST and ElasticSearch and have to index some documents but encounters some issues when it comes to upserting.

Each document has an ID.

When pushing a document with a certain ID, if the index already contains a document with this ID, I'd like to replace the doc. And if no document with this ID exists, it would simply be about inserting the document.

At the moment, I'm using client.IndexAsync but it generates duplicates. And client.UpdateAsync requires an existing ID if I understood it well.

I found this in ES documentation, but there's nothing related in NEST. Do I have to use the low level client or is there something I'm missing in NEST?

Thanks


Solution

  • Was in fact related to wrongly generated IDs which prevented upserting.