Elasticsearch.NET Disable ID inference

(Jeremy Smith) #1

I have a collection of c# POCOs that I cannot modify. Some of them have a field called "id" that gets picked up as the _id in the mapping. These obj have duplicate id, which causes the last inserted obj to upsert over the others.

Is there a way for me to set the client to ignore inference of the id by using reflection to find the name "id"?

(Martijn Laarman) #2

You can influence the inference in code without touching the class itself as well

 .DefaultMappingFor<MyDTO>(m => m
        .IdProperty(p => p.OtherName)

See more examples here: https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/ids-inference.html

(system) #3

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