Elasticsearch 6自引用循环错误

时间:2018-06-12 03:40:34

标签: elasticsearch asp.net-core

我正在尝试进行批量操作:

var response = await _client.BulkAsync(new BulkRequest
{
    Operations = list.Select(x => new BulkIndexOperation<T>(x)).Cast<IBulkOperation>().ToList(),
    Refresh = Elasticsearch.Net.Refresh.True
});

我得到了这个引用循环错误:

  

JsonSerializationException:检测到自引用循环   属性“类别”的属性“父级”。路径'孩子[0]'。

我已经看到了这方面的解决方案,我认为我很接近,但我不确定在哪里设置忽略?

var connection = new ConnectionSettings(
                new SingleNodeConnectionPool(new System.Uri(settings.Value.ElasticSearchUrl)),
                new HttpConnection(), 
                new ConnectionSettings.SourceSerializerFactory((jsonSettings, nestSettings) => 
                    jsonSettings.?????)
            );

******** UPDATE ************** 我得到了它的工作:

   var connection = new ConnectionSettings(
        new SingleNodeConnectionPool(new System.Uri(settings.Value.ElasticSearchUrl)),
        sourceSerializer: (builtin, setting) => new JsonNetSerializer(
            builtin, setting, () => new JsonSerializerSettings {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            }
        ));

0 个答案:

没有答案