# C# NEST - Elastic search \_Id mapping to DocumentId fails and results in duplicate results in ES

**URL:** https://discuss.elastic.co/t/c-nest-elastic-search-id-mapping-to-documentid-fails-and-results-in-duplicate-results-in-es/306027
**Category:** Elasticsearch
**Tags:** language-clients
**Created:** [May 31, 2022, 10:13am UTC](https://discuss.elastic.co/t/c-nest-elastic-search-id-mapping-to-documentid-fails-and-results-in-duplicate-results-in-es/306027 "2022-05-31T10:13:18Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Sohaib\_Ameen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sohaib_ameen/32/106389_2.png) [@Sohaib\_Ameen](https://discuss.elastic.co/u/Sohaib_Ameen)
#### Post date: [May 31, 2022, 10:13am UTC](https://discuss.elastic.co/t/c-nest-elastic-search-id-mapping-to-documentid-fails-and-results-in-duplicate-results-in-es/306027/1 "2022-05-31T10:13:18Z")

</div>

Hello everyone,  
I am using C# NEST functions to create indexes in Elasticsearch and tried to map \_id field with a custom field of DocumentId but it does not work as it put some random string value in \_id instead of document Id. I am using the same function for another model and it seems to be working fine but not in this case.  
Logger.Debug($"Begin process create content index for tenant name: {indexName}");  
var settings = new ConnectionSettings(new Uri(OpusConfiguration.GetEsUrl()))  
.ServerCertificateValidationCallback(CertificateValidations.AllowAll)  
.DefaultIndex(indexName)  
.InferMappingFor(m =\> m.IdProperty(p =\> p.DocumentId));  
public class FMContextSearch  
{  
public long DocumentId { get; set; }  
public long TenantId { get; set; }  
public string TenantName { get; set; }  
public string Title { get; set; }  
public string Description { get; set; }  
public string DocumentName { get; set; }  
public string Categories { get; set; }  
public string Departments { get; set; }  
public string Attributes { get; set; }  
public string DocumentType { get; set; }  
public string Captions { get; set; }  
public string FullText { get; set; }  
public string Urls { get; set; }  
public string ProcessNames { get; set; }  
public string LocaleName { get; set; }  
public string LastModifiedTime { get; set; }  
public List GlobalContext { get; set; }  
public List StepContexts { get; set; }  
public List Modes { get; set; }  
}  
3:09  
\_id field is not being mapped with document Id due to which on updating the record, it puts a duplicate entry

 ![image (5)](https://us1.discourse-cdn.com/elastic/original/3X/5/7/576624eff71106b79c7e0f50a26fb0120cde8c8c.png)

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 28, 2022, 10:13am UTC](https://discuss.elastic.co/t/c-nest-elastic-search-id-mapping-to-documentid-fails-and-results-in-duplicate-results-in-es/306027/2 "2022-06-28T10:13:23Z")

</div>

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