Hi Everyone,
We are trying to add the object in Bulk descriptor, when the descriptor count reaches 500 we are pushing the data to ES. But the data is getting collapsed. Eg. 1st document data is pushing properly, instead of pushing 2nd document data it is inserting 1st document data. We are creating Unique Id for each document, still the error exists. We are creating the lock object for concurrency call.
Any help will be appreciated. Thanks in advance.
Code:
public static void ESSupplierStatsDataUpload(SupplierStats ObjSupplierStats)
{
try
{
if (ElasticSearchCredentials.EnableElasticSearch)
{
lock (_object)
{
//Checks the count in descriptor and doing bulk upload
descriptor.Index(op => op.Index("mystiflysupplierstats")
.Document(ObjSupplierStats)
);
var count = (descriptor as IBulkRequest).Operations.Count;
if (count == 500)
{
var result = client.Bulk(descriptor );
descriptor = new BulkDescriptor();
}
}
}
}
catch (Exception e)
{
//Logging exception
throw;
}
}