简体   繁体   English

使用 NEST (ElasticSearch) 插入文档

[英]Upsert document with NEST (ElasticSearch)

I'm new to NEST and ElasticSearch and have to index some documents but encounters some issues when it comes to upserting.我是 NEST 和 ElasticSearch 的新手,必须索引一些文档,但在更新插入时遇到了一些问题。

Each document has an ID.每个文档都有一个 ID。

When pushing a document with a certain ID, if the index already contains a document with this ID, I'd like to replace the doc.推送具有特定ID的文档时,如果索引已经包含具有此ID的文档,我想替换该文档。 And if no document with this ID exists, it would simply be about inserting the document.如果不存在具有此 ID 的文档,则只需插入文档即可。

At the moment, I'm using client.IndexAsync but it generates duplicates.目前,我正在使用client.IndexAsync但它会生成重复项。 And client.UpdateAsync requires an existing ID if I understood it well.如果我理解得很好, client.UpdateAsync需要一个现有的 ID。

I found this in ES documentation , but there's nothing related in NEST.在 ES 文档中找到了这个,但在 NEST 中没有任何相关内容。 Do I have to use the low level client or is there something I'm missing in NEST?我必须使用低级客户端还是 NEST 中缺少某些东西?

Thanks谢谢

实际上与阻止更新插入的错误生成的 ID 有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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