There's a fundamental difference between the create and index APIs in Elasticsearch;
- create API will create the document if it does not exist, and will return an error if it does exist. The create API request must contain the index, type and id in the request URI. The id field can be inferred from the POCO or can be explicitly set on the request.
- index API will create the document if it does not exist and will overwrite the document if it does exist. Passing an id is optional, and if an id is not passed, Elasticsearch will generate an id for the document.
This difference is reflected in the Create()
and Index()
methods exposed on the .NET clients.