Skip to content

Modifying NEST JsonSerializer settings does not seem to work #535

Closed
@crunchie84

Description

@crunchie84

Hello,

I am using NEST NuGet package v 0.12.0.0 to connect to my ElasticSearch. I want my Enum values to be send to ElasticSearch as their ToString() instead of their index/int value.

I have tried the following:

  var settings = new ConnectionSettings(elasticSearchUri)
    .SetDefaultIndex("my-index")
    .SetJsonSerializerSettingsModifier(m =>
    {
      if (m.Converters == null)
        m.Converters = new List<JsonConverter>(); //required because of nullrefs?
      m.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter());
    });

But it looks like it keeps sending the Enum values as ints.

I have also tried to modify the serialiserSettings after constructing the ConnectionSettings like so:

  connectionSettings.ModifyJsonSerializerSettings(new JsonSerializerSettings
  {
    Converters = new[] {new Newtonsoft.Json.Converters.StringEnumConverter()}
  });

but both seem to be ignored. Am i missing something here? Could you please provide some more details how to modify the JsonSerializerSettings?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions