private async Task HandleFailureAsync(ReindexWorkItem workItem, BulkIndexByScrollFailure failure) { _logger.LogError("Error reindexing document {Index}/{Type}/{Id}: [{Status}] {Message}", failure.Index, failure.Type, failure.Id, failure.Status, failure.Cause.Reason); var gr = await _client.GetAsync <object>(request : new GetRequest(failure.Index, failure.Type, failure.Id)).AnyContext(); if (!gr.IsValid) { _logger.LogError("Error getting document {Index}/{Type}/{Id}: {Message}", failure.Index, failure.Type, failure.Id, gr.GetErrorMessage()); return; } var document = new JObject(new { failure.Index, failure.Type, failure.Id, gr.Version, gr.Parent, gr.Source, failure.Cause, failure.Status, gr.Found, }); var indexResponse = await _client.IndexAsync(document, d => d.Index(workItem.NewIndex + "-error").Type("failures")).AnyContext(); if (!indexResponse.IsValid) { _logger.LogError("Error indexing document {Index}/{Type}/{Id}: {Message}", workItem.NewIndex + "-error", gr.Type, gr.Id, indexResponse.GetErrorMessage()); } }
private async Task HandleFailureAsync(ReindexWorkItem workItem, BulkIndexByScrollFailure failure) { _logger.LogError("Error reindexing document {Index}/{Id}: [{Status}] {Message}", workItem.OldIndex, failure.Id, failure.Status, failure.Cause.Reason); var gr = await _client.GetAsync <object>(request : new GetRequest(workItem.OldIndex, failure.Id)).AnyContext(); if (!gr.IsValid) { _logger.LogErrorRequest(gr, "Error getting document {Index}/{Id}", workItem.OldIndex, failure.Id); return; } _logger.LogRequest(gr); string document = JsonConvert.SerializeObject(new { failure.Index, failure.Id, gr.Version, gr.Routing, gr.Source, failure.Cause, failure.Status, gr.Found, }); var indexResponse = await _client.LowLevel.IndexAsync <VoidResponse>(workItem.NewIndex + "-error", PostData.String(document)); if (indexResponse.Success) { _logger.LogRequest(indexResponse); } else { _logger.LogErrorRequest(indexResponse, "Error indexing document {Index}/{Id}", workItem.NewIndex + "-error", gr.Id); } }