简体   繁体   中英

Index/Update data in elasticsearch using NEST in same call

I am indexing metadata in ElasticSearch using NEST. I want to update metadata if it is already present. Does NEST has any API's to index data and update if the data is present?

How do we handle this?

You are looking for the upsert functionality within the update API.

On NEST: http://nest.azurewebsites.net/nest/core/update.html And on ES: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html#upserts

From the NEST example:

client.Update<ElasticsearchProject, object>(u => u
    .Id(1)
    .Doc(new { Country = "United States"})
    .Upsert(new ElasticsearchProject { Id = 1, Country = "United States" })
);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM