elasticsearch-net icon indicating copy to clipboard operation
elasticsearch-net copied to clipboard

How to extend the serializer in the latest version?

Open gpetrou opened this issue 4 months ago • 1 comments

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?

gpetrou avatar Oct 18 '24 04:10 gpetrou