【发布时间】:2021-07-19 15:14:36
【问题描述】:
在下面的代码中,我有多个脚本,其中一些文档不存在,所以目前只需更新现有的脚本并为不存在的脚本返回错误。 无论如何只是更新现有的并忽略其余部分并返回有效状态?
var script = "new InlineScript($@"if (ctx._source.containsKey('[RemovedField]'))" +
$"{{ ctx._source.remove(\"{RemovedField}\")}}");"
foreach(var update in updates)
var operation = new BulkUpdateOperation<IFieldOperation, object>(update.Id)
{
Script = script,
ScriptedUpsert = false,
//Upsert = don't want upsert if doc not exist
Index = [Index Name]
};
operations.Add(operation);
var response = await _client.BulkAsync(new BulkRequest {
Operations = new BulkOperationsCollection<IBulkOperation>(operations)
})
// response.IsValid is equal false which I want to find the way to return as true
【问题讨论】:
-
你能澄清你的问题并从你的文档和脚本中举出一些例子吗?
-
已经更新了上面的代码,希望能帮助你理解我的问题
标签: elasticsearch