Upsert a document when document id is autogenerated using upsert?

According to the docs, on the Update API

The <_id> field is required.

I have a bulk insert process which is sometimes known to insert duplicates given a particular scenario.

The ids for us, are auto generated so how does one use the Update API with Upsert functionality give this limitation in our set-up ?

Do we start generating the ids upfront and perform a simple calculation or does the API have a deterministic approach where the document can be identified using a different unique value ?

My hope was to use the DocumentPath class but under the covers, this too uses an id value.

I am using the nest sdk with c# (dotnet core 7).

Thanks for reading.

No it does not. You need to supply the correct index name and document id.

If you can change the generated id so it is deterministic based on the data in the event, that may be a way to go. If you can not do this you will generally need to search to see if the document exists before inserting it, which adds a lot of overhead.

1 Like

Ah that figures - thank you for responding.

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