You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Need a way to fail CreateMany if any inserts fail.
Describe the solution you'd like
CreateMany has Option to pass, to enable atomic writes
Describe alternatives you've considered
Deleting records after response comes, but this slows down performance by forcing a second call.
public async Task<Result> InsertAllAsync(TE[] objs, CancellationToken ct)
{
var res = await _client.BulkAsync(
b => b.Index(_dbName)
.CreateMany(objs)
.Refresh(GetRefresh()), ct).ConfigureAwait(false);
var allIds = objs.Select(x => x.Id).ToArray();
var result = new Result { PassedIds = allIds };
if (!res.IsValidResponse)
{
// TODO: Remove Hack once elastic team gives recommendation:
var failedIds = res.ItemsWithErrors.Select(x => x.Id).ToArray();
var passedIds = allIds.Except(failedIds).ToArray();
await DeleteAllAsync(passedIds, ct);
result.PassedIds = [];
result.FailedIds = allIds;
}
return result;
}
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Hi @DR9885 , could you please contact the general Elasticsearch support for this?
As far as I know there is no better way of achieving this, since Elasticsearch does not support transactions. This however is unrelated to the .NET client.
Is your feature request related to a problem? Please describe.
Need a way to fail CreateMany if any inserts fail.
Describe the solution you'd like
CreateMany has Option to pass, to enable atomic writes
Describe alternatives you've considered
Deleting records after response comes, but this slows down performance by forcing a second call.
Additional context
N/A
The text was updated successfully, but these errors were encountered: