3

我正在尝试更改 Newtonsoft 在使用 Nest 序列化对象时处理自引用循环的方式。我正在使用 Newtonsoft.Json 4.5.11 并且我坚持使用该版本,Nest 是 0.11.7.0 版本,我正在使用的代码片段是

var searchBoxUri = new Uri("Url");

var elasticSettings = new ConnectionSettings(searchBoxUri)
    .SetDefaultIndex("sample");

elasticSettings.SetJsonSerializerSettingsModifier(s => {
    s.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
});

var client = new ElasticClient(elasticSettings);

client.Index(currentPage);

使用此代码,我在堆栈跟踪中收到以下异常

[JsonSerializationException: Self referencing loop detected with type 'some type'.]

那么,为什么客户端不使用我配置的设置或者我在这里遗漏了什么?

4

1 回答 1

3

这是 0.11.7.0 版本中的一个错误,经过一些重大重构以使序列化更精简。

另请参阅https://github.com/Mpdreamz/NEST/pull/382

将在 0.11.8/0 中修复

于 2013-11-13T09:14:26.820 回答