当我尝试使用 BulkExecutor 更新 CosmosDb 中的属性之一时出现错误。错误消息是“索引超出范围。必须为非负数且小于集合的大小。
参数名称:索引”
重要的一点 - 我没有在我的集合上定义分区键。
这是我的代码:
SetUpdateOperation<string> player1NameUpdateOperation = new SetUpdateOperation<string>("Player1Name", name);
var updateOperations = new List<UpdateOperation>();
updateOperations.Add(player1NameUpdateOperation);
var updateItems = new List<UpdateItem>();
foreach (var match in list)
{
string id = match.id;
updateItems.Add(new UpdateItem(id, null, updateOperations));
}
var executor = new Microsoft.Azure.CosmosDB.BulkExecutor.BulkExecutor(_client, _collection);
await executor.InitializeAsync();
var executeResult = await executor.BulkUpdateAsync(updateItems);
var count = executeResult.NumberOfDocumentsUpdated;
我缺少什么?
如果我在没有分区键的集合上运行批量执行器,我会收到相同的错误。如果我使用包含它的集合运行它并指定它,则批量执行器可以正常工作。
很确定他们现在不支持通过批量执行器 api,只需使用普通的 cosmos api 来更新文档作为目前的解决方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)