0

I am trying to use the .Net client Nest 6.2 for ES. I am trying to configure the default settings for number of shards and replicas. this is the code I found online: using index settings

var indexName= "indexName";
var client = this.ConnectedClient;
var settings = new IndexSettings();
settings.NumberOfReplicas = 1;
settings.NumberOfShards = 5;    
client.CreateIndex(indexName, settings);

but the last line is raising a compilation error:

cannot convert from Nest.INdexSettings to System.Func

1 Answer 1

1

There are two CreateIndex calls available in NEST but neither take an IndexSettings object. See here for details https://github.com/elastic/elasticsearch-net/blob/02bdf28788e657cffc253598d7766820f9eed62e/src/Nest/Indices/IndexManagement/CreateIndex/ElasticClient-CreateIndex.cs

You can use the fluent syntax to do this in a much cleaner way

client.CreateIndex(indexName, i => i.Settings(s => s 
.NumberOfShards(5) .NumberOfReplicas(1)))
Sign up to request clarification or add additional context in comments.

2 Comments

thank you. How do I add the object itself to the index?
Which object are we talking about? If the document, then use the BulkAll call if you have multiple docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.