To accept a client side customized UUID on the _id field i had to change the: dynamic: strict property to true.
All this time, we have been using strict and auto generated UUIDs for the _id field.
When inspecting, the newly inserted document, i noticed a new field is added: id whose contents are matched exactly onto the _id metadata field.
Is this the expected behaviour, is this right way of achieving what i set out to do, which is to generate UUIDs, client side and then push to ELASTIC via bulk insert method.
I am using c# and the nest nuget package in dotnet 7.
When going back to the dynamic mode: "strict", there is no winning with Elastic Search API. I get confusing and conflicting error messages:
"Field [_id] is a metadata field and cannot be added inside a document. Use the index API request parameters.""
Or "type" : "strict_dynamic_mapping_exception", "reason" : "mapping set to strict, dynamic introduction of [id] within [_doc] is not allowed",
I do not want to add a new field/property to the document, i just want to customize the metadata field called: _id.
I am not the C# expert.... I will have to take a look but I think it is important that you understand the underlying calls... you do not set _id as a normal property that is the error message you are getting.
It would be cool if you could refer my Q to a c# expert at ES. That would be greatly appreciated.
I have tried the _bulk endpoint and the i can see the mapped _id properties when the error messages are logged and handled. But every document gets rejected. Let me try again.
I tried the .BulkAll() method with a list of documents passed to it. Each document has a pregenerated UUID assigned to a _id property on each document.
The DroppedDocumentCallback() callback function is triggered revealing no errors why the document was dropped. Looking closely at the logs, i see:
You can see two different ids have been generated, one by me client side (Ba/FyFrAslLo9b82OurV) and another (hWLfXowBADcS-dXjXrm2) by, ES API - this is revealed by inspecting the: BulkResponseItemBase.Id property.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.