Elasticsearch.Net/Nest issue with API after upgrade to 6.2.3

In ES 5.6, using Nest API, we were doing Create operation using following code...

var descriptor = new BulkDescriptor();
descriptor.Index<JObject>(i => i
                                  .Index(esClient.IndexName)
                                  .Type(documentType)
                                  .Document(document));
esClient.Client.BulkAsync(descriptor);

This code used to work absolutely fine, and we were seeing the documents were inserting appropriately in the ES 5.6, example -

{
"_index": "lsss_2015_dummy",
"_type": "serviceobject",
"_id": "74401145-1751-4253-8dfe-a0200065e0b2",
"_version": 4266,
"_score": 1,
"_source": {
"ServiceId": "74401145-1751-4253-8dfe-a0200065e0b2",
"Version": "47b62897-c11f-4a17-8802-303cf912d119",
"Type": 1
}
}

After upgrading to ES 6.2.3 and Updating Nest/ES.NET API, this does not work anymore, it actually insert the document with the field, but document does not contains any values..
example

{
"_index": "lsss_2015_dummy",
"_type": "serviceobject",
"_id": "74401145-1751-4253-8dfe-a0200065e0b2",
"_version": 4266,
"_score": 1,
"_source": {
"ServiceId": "",
"Version": "",
"Type": ""
}
}

Anyone had similar issue, or any comments on this about how to resolve it , I am not sure if it is because of jObject type, I looked at the upgrade documentation, didnt find anything related to it..

Please help.

Could you please format your code using </> button in the toolbar; it makes the question much easier to read :slightly_smiling_face:

If you're using JObject as the document type, or your document contains JObject, you will need to also reference the NEST.JsonNetSerializer nuget package and hook up the JsonNetSerializer as follows

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

var client = new ElasticClient(connectionSettings);

This is required because NEST 6.x removed the direct dependency on Json.NET by IL-merging, internalizing and re-namespacing it. One of the changes this brings about is that now, NEST does not know how to specially handle Newtonsoft.Json.Linq.JObject, so the dependency on NEST.JsonNetSerializer which does know how to handle that type specially, is needed.

Thanks so much Russ :), will format my code ...

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.