Creating Elasticsearch Indexes from JSON with Elastic.Clients.Elasticsearch in .NET

I'm currently updating my NEST client, which is deprecated, to the latest Elasticsearch client, Elastic.Clients.Elasticsearch. Previously, with NEST, I utilized the low-level client to create indexes from a JSON file containing mappings and settings, like so
var response = await this.client.LowLevel.Indices.CreateAsync(formattedIndexName, bytes, ctx: cancellationToken);

However, this functionality is not available in the latest client. What would be the recommended approach for achieving a similar outcome with the latest client?

1 Like

Hi @Jacques_du_Plessis,

please have a look at the very last paragraph in the migration guide:

It shows an example of how to use the low level transport. It's a little bit more work than what you've been doing before - but not that much. Besides the json payload, you must set the correct HTTP method and path for the endpoint and configure query parameters (these ones you probably don't need for your use-case).

The endpoint is documented here:

For your case, the method and path is PUT /my-index-000001 where my-index-000001 is the name of the index you want to create.

1 Like

Hi thanks for the quick reply.

I dud read the migration document but think I missed that last section.

I will give it a go.