elastic/elasticsearch-net

BulkAsync insert :internal error:Input string was not in a correct format

Closed this issue · 3 comments

Elastic.Clients.Elasticsearch version: 8.15.1

Elasticsearch version:8.11

.NET runtime version:6.0

Operating system version:centos7.6

Description of the problem including expected versus actual behavior:
A clear and concise description of what the bug is.

Steps to reproduce:
public async Task BulkIndexAsync(IEnumerable documents, string indexName = null) where T : class
{
var index = GetIndexName(indexName);

var bulkRequest = new BulkRequest(index)
{
    Refresh = Refresh.False,// 关键:不等待刷新
    Operations = new List<IBulkOperation>()
};

foreach (var doc in documents)
{
    bulkRequest.Operations.Add(new BulkIndexOperation<T>(doc));
}

var response = await _client.BulkAsync(bulkRequest);
if (!response.IsValidResponse)
{
    Console.WriteLine("批量索引存在错误: {ErrorCount}", response.ItemsWithErrors.Count());
}

return response;

}

Call:await _elasticsearchService.BulkIndexAsync(vmDataList)

Abnormal problem::internal error:Input string was not in a correct format.,StackTrace: at System.Text.StringBuilder.FormatError()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.IO.StreamWriter.WriteFormatHelper(String format, ParamsArray args, Boolean appendNewLine)
at System.IO.StreamWriter.WriteLine(String format, Object arg0)
at System.IO.TextWriter.SyncTextWriter.WriteLine(String format, Object arg0)
at System.Console.WriteLine(String format, Object arg0)
at DMS.CRMS.Common.ServiceExtensions.ElasticsearchService.BulkIndexAsync[T](IEnumerable`1 documents, String indexName)

@hailang2ll Correct me, if I'm wrong, but the callstack seems to indicate an exception in your own Console.WriteLine code. Not sure what I should do about this.

This issue is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 2 days.

This issue was closed because it has been stalled for 2 days with no activity.