NEST mapping of Dictionary<string,dynamic> getting empty arrays NEST mapping of Dictionary<string,dynamic> getting empty arrays elasticsearch elasticsearch

NEST mapping of Dictionary<string,dynamic> getting empty arrays


I suspect this is related to the internalization of Json.NET in 6.x and the use of dynamic in your code.

dynamic will actually be deserialized to JToken types by Json.NET, which NEST will not know how to serialize, since the internalized Json.NET for all intents and purposes can be considered a different assembly that knows nothing about Newtonsoft.Json types.

To fix, you can reference Nest.JsonNetSerializer nuget package and hook up the JsonNetSerializer as the serializer for NEST to use for your documents

var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200"));var connectionSettings =    new ConnectionSettings(pool, sourceSerializer: JsonNetSerializer.Default);var client = new ElasticClient(connectionSettings);