I'm trying to update documents in the elastic search using C# Nest. I have Azure service bus trigger function which supplies the data to be updated. Below are the steps I'm performing to update document.
- Get the record from Elastic Search index by ID
- Make the changes
- update the record by ID
If I'm testing with a single message, the logic is working fine. Incase of concurrent requests, the Elastic search is retuning null response.
Below are the details of the servicebus message and Nest logic.
Message :
ID Data to be updated 12345678 XXXXXXXXXXXXXXXX
Business Logic :
public async Task Update(string message)
{
var obj = JsonConvert.DeserializeObject<Model>(topicMessage.Record);
SearchResponse searchResponse = null;
var esResult = await _elasticClient.GetAsync<SearchResponse>(obj.Id);
searchResponse = esResult?.Source;
if (searchResponse != null)
{
// Update logic which is working fine
}
else
{
throw new Exception($"Record with id:{obj.Id} not found in ES");
}
}
If I'm processing 10000 records at a time, then about 500 to 1000 records are returning null (Even the record with Id exists on ES index).
I need some help for handling concurrent requests with fast processing and less failures.
Note : Id is not null or empty in any of the message.