elasticsearch,nest,C#,elasticsearch,Nest" /> elasticsearch,nest,C#,elasticsearch,Nest" />

C# 使用Nest C的ElasticSearch部分更新#

C# 使用Nest C的ElasticSearch部分更新#,c#,elasticsearch,nest,C#,elasticsearch,Nest,我想部分更新elasticsearch记录。我创建了索引方法,但它基本上覆盖了整个文档。我有一个想部分更新记录的场景。有人能告诉我如何做到这一点吗。这是我的索引方法 public async Task<IIndexResponse> IndexAsync<T>(T data, string indexName, string typeName) where T : class { if (indexName == null) {

我想部分更新elasticsearch记录。我创建了索引方法,但它基本上覆盖了整个文档。我有一个想部分更新记录的场景。有人能告诉我如何做到这一点吗。这是我的索引方法

 public async Task<IIndexResponse> IndexAsync<T>(T data, string indexName, string typeName) where T : class
    {
        if (indexName == null)
        {
            throw new ArgumentNullException("Index name is null. Please provide index name to insert the data.");
        }

        return await Client.IndexAsync<T>(data, i => i
            .Index(indexName)
            .Type(typeName)
            .OpType(OpType.Create));
    }
公共异步任务IndexAsync(T数据、字符串indexName、字符串typeName),其中T:class
{
if(indexName==null)
{
抛出新ArgumentNullException(“索引名为null。请提供索引名以插入数据。”);
}
return wait Client.IndexAsync(数据,i=>i
.Index(索引名)
.Type(typeName)
.OpType(OpType.Create));
}

也许这些(,)答案会对你的问题有所帮助。谢谢你的参考帖子。我知道了如何实现更新。你应该调用“更新”方法。看一看