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

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

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