Upgrading from Elasticsearch 5.x to 6.x - How to Create Index in C#

I have an application that has been working fine for years. Recently I am being forced to switch from Elasticsearch v5 to v6. I have a lot of .NET C# code that use the Elasticsearch.Net and Elasticsearch Low Level APIs for .NET to communicate with Elasticsearch.

I found the list of all the breaking changes.

What I need now, is a little more help and sample code.

In v5, I created an index like so:

var LowLevelClient = new ElasticLowLevelClient(_Settings);
var indexName = "MyIndexName";
PostData jsonPostData = CreateMappingJson(entityId);
var result = LowLevelClient.IndicesCreate<Object>(indexName, jsonPostData);
if (!result.Success)

On the page above of the breaking changes, you will see the following: Deleted: IndicesCreate(String, PostData, Func) Added: IndicesCreate(String, PostData, CreateIndexRequestParameters)

I am happy to change to the new method, but I don't understand. Do I have to create my own class that inherits from IElasticsearchResponse? Something like this?

public class MyResponse : IElasticsearchResponse
    {
        public MyResponse()
        {
        }

        public IApiCallDetails ApiCall { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

        public bool TryGetServerErrorReason(out string reason)
        {
            throw new NotImplementedException();
        }
    }

If I do that, then I can update my original code to the following:

var result = LowLevelClient.IndicesCreate<MyResponse>(indexName, jsonPostData);
if (!result.ApiCall.Success)

That gets ride of the compiler errors.

My question is, what should my MyResponse class look like. I am sure what I have done will not work yet.

Thanks!

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