1

I am trying to insert\bulk insert data to Elastic using NEST API.

Can someone provide me the example using NEST?

Thanks, Sameer

1 Answer 1

3

NEST documantation contains examples how to do this e.g.:

var descriptor = new BulkDescriptor();

foreach (var i in Enumerable.Range(0, 1000))
{
    descriptor.Index<ElasticSearchProject>(op => op
        .Document(new ElasticSearchProject {Id = i})
    );
}

var result = client.Bulk(descriptor);

Also you can use IndexMany which is quite useful

var documents= new List<ElasticSearchProject> {...};
client.IndexMany(documents);

Good luck.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Rob, I have a question. I know NEST is strongly typed. But is there any way to push JSON string to ElasticSearch instead of using classes?
For raw queries you can still use NEST, but in case of indexing data you should have look at Elasticsearch.Net I guess. Hope it helps you.

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.