插入具有相同分区键值和不同“ id”值的文档

时间:2019-04-11 15:21:12

标签: azure azure-cosmosdb azure-cosmosdb-sqlapi

在给我一个新的'id'但分区键与现有文档的分区键相同时,我需要插入一个新文档。但是它给了我一个DocumentClientException。为什么是这样?我不应该能够拥有具有相同分区键值的多个文档吗?

它给了我这个错误,尽管我实际上是在给它一个不存在的新'id'。

com.microsoft.azure.documentdb.DocumentClientException: Entity with the specified id already exists in the system., 
RequestStartTime: 2019-04-11T15:36:19.7657781Z, RequestEndTime: 2019-04-11T15:36:19.7657781Z, Number of regions attempted: 1
ResponseTime: 2019-04-11T15:36:19.7657781Z, StoreResult: StorePhysicalAddress: rntbd://sn4prdapp19-docdb-1.documents.azure.com:14030/apps/59d3b9ef-17ca-4bbf-8a11-39d0199a8d29/services/27f87c68-85a5-44ec-b1cf-bfc46347392b/partitions/6ddeca7e-1056-4ed7-b70f-5472223dde1c/replicas/131974948271521006p/, LSN: 495, GlobalCommittedLsn: 495, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 409, SubStatusCode: 0, RequestCharge: 1.57, ItemLSN: -1, SessionToken: 0#495#4=-1, UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Create
, Microsoft.Azure.Documents.Common/2.2.0.0, StatusCode: Conflict

1 个答案:

答案 0 :(得分:0)

问题涉及集合中定义为唯一的单独字段