How to get the _id of a document easily? [C#]

Hi @Motsols,

I don't think there is a better solution for this. As you can see in the JSON response, _id is stored outside of the _source object, which is just the way ES works.

If you use Elastic.Clients.Elasticsearch for ingestion, you should indeed set the Id property of your object to something unique, like a GUID.

The client automatically checks, if the document has a property which is called Id (as well considers some variations) and uses this as the _id meta-data during ingestion, update operations, etc.

This way, the id is effectively stored twice: One time as the _id meta-data and another time inside the id field of the _source object.

Another solution could be to set-up an ingest pipeline that automatically populates the id property of your document with the value from the _id meta-data.