Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modify serializersettings for Nest and Elastic Search

I'm trying to change how Newtonsoft handles self referencing loops when using Nest to serialize an object. I'm using Newtonsoft.Json 4.5.11 and I'm stuck with that version, Nest is version 0.11.7.0 and the code snippet I'm using is

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);

using this code I'm getting the following exception in the stack trace

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

So, why does't the client use the settings I have configured or am I missing something here?

like image 917
marcus Avatar asked Dec 19 '25 19:12

marcus


1 Answers

This is a bug in the 0.11.7.0 release following some heavy refactoring to make the serialization leaner.

See also https://github.com/Mpdreamz/NEST/pull/382

Will be fixed in 0.11.8/0

like image 71
Martijn Laarman Avatar answered Dec 22 '25 19:12

Martijn Laarman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!