Docs for indexing a document leads to an error [Elasticsearch.NET 8.13.12]

I'm using the latest .NET client for elasticsearch.

The docs shows this as an example of how to index documents: Getting started | Elasticsearch .NET Client [8.9] | Elastic

When writing the same code in VS Community 2022 17.9.7 as well as VS Code it shows an error that the call is ambiguous:

Pasting the error here as well for searchability.
error CS0121: The call is ambiguous between the following methods or properties: 'ElasticsearchClient.IndexAsync(TDocument, IndexName, CancellationToken)' and 'ElasticsearchClient.IndexAsync(TDocument, Id?, CancellationToken)'


Is casting the string the correct way to index documents now? If so I'd love to see the documentation updated to reflect the recent changes to the .NET client.

var response = await _esClient.IndexAsync(doc, (IndexName)"my_index");

Edit:
My post was flagged as spam for being overly promotional. What is promotional? I don't see why this would be flagged, as it may help future people with the same question find the answer without posting their own question.

Hi @Motsols,

casting to IndexName is one option. The other one would be to use a named argument like:

client.IndexAsync(doc, index: „my_index“)

I think the ambiguity comes from the fact that both, IndexName and Id, have implicit conversion operators from string.

Still looking for a better solution here, but if there is no good way to improve this situation, I’ll make sure to update the docs.

I think it's still good to keep the docs updated while you investigate as it is one bump on the road to a smooth implementation of Elasticsearch.