elasticsearch-net
elasticsearch-net copied to clipboard
How to extend the serializer in the latest version?
Once again there are breaking changes in a patch version. Before the latest version, we had the following class:
internal class ExtendedSystemTextJsonSerializer : SystemTextJsonSerializer
{
public ExtendedSystemTextJsonSerializer(IElasticsearchClientSettings elasticsearchClientSettings)
: base(elasticsearchClientSettings)
{
JsonSerializerOptions options = DefaultSourceSerializer.CreateDefaultJsonSerializerOptions(includeDefaultConverters: true);
options.Converters.Add(new ObjectConverter());
Options = DefaultSourceSerializer.AddDefaultConverters(options);
}
protected JsonSerializerOptions Options { get; set; }
protected override JsonSerializerOptions CreateJsonSerializerOptions() => Options;
}
We were calling it as in the following code:
ElasticsearchClientSettings elasticsearchClientSettings = new(
nodePool,
sourceSerializer: (defaultSerializer, settings) =>
new ExtendedSystemTextJsonSerializer(settings));
How is this supposed to be transformed now in the latest version? We do not need the IElasticsearchClientSettings
anymore?