Bulk write on ElasticSearch 2.0 NEST 2.0 throws a stackoverflow exception

痴心易碎 提交于 2019-12-13 19:04:59

问题


I was using bulk insertion on my ElasticSearch 1.0 and NEST 1.0. Now I moved to ElasticSearch 2.0 and NEST 2.0 and the bulk insertion throws a stackoverflow (!) exception. My gut feeling is that an infinite recursion is taking place and it consumes the entire stack.

this is my POCO

[ElasticsearchType(Name = "MyDoc")]
public class MyDoc: DynamicResponse
{
    [String(Store = false, Index = FieldIndexOption.NotAnalyzed)]
    public string HistoryId { get; set; }

    [String(Store = false, Index = FieldIndexOption.NotAnalyzed)]
    public string FileId { get; set; }

    [Date(Store = false)]
    public DateTime DateTime { get; set; }
}

That's how I create the mapping:

elastic.Map<MyDoc>(m => m.Index(indexName).AutoMap());

Bulk insertion is done in two steps

First I create the descriptor:

        List<dynamic> dataRecordList;

        var descriptor = new BulkDescriptor();

        if (dataRecordList == null || dataRecordList.Count == 0)
        {
            return;
        }

        foreach (var dataRecord in dataRecordList)
        {
            var nonClosedDataRecord = dataRecord;

            descriptor.Index<object>(record => record.Index(indexName).Type("MyDoc").Document(nonClosedDataRecord));
        }

Then I call the NEST bulk() method

        var bulkResponse = elastic.Bulk(d => descriptor);

I get the stackoverflow exception inside the foreach, when calling descriptor.Index()

EDIT

An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

Unfortunately no more details are available as the exception occurred on an external code (system or framework?)

来源:https://stackoverflow.com/questions/35721566/bulk-write-on-elasticsearch-2-0-nest-2-0-throws-a-stackoverflow-exception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!