azure-cosmosdb - 在 CosmosDb 中使用 BulkExecutor 时索引无效异常

标签 azure-cosmosdb bulkupdate

当我尝试使用 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 来更新文档作为现在的解决方法。

关于azure-cosmosdb - 在 CosmosDb 中使用 BulkExecutor 时索引无效异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53698740/

相关文章:

python - 在 bulk_create Django 中捕获特定的失败记录

azure - 是否可以使用 @azure/cosmos sdk 创建新的 CosmosDB 帐户?

c# - 如何构建涉及大量地理位置计算的应用程序?

使用存储过程的 Azure DocumentDB 分页?

sql - 在 Postgres 中批量更新

mysql - 批量更新大型 InnoDB 表中未索引的列

azure - 函数进入休眠状态后,Cosmos db 更改提要触发器不会触发

c# - 查询 DocumentDB 中的分区列表(和/或分区键值)

java - 如何在java中使用mongodb实现批量updateOne