我正在尝试在我们的CosmosDB上的某些集合上创建唯一索引。根据微软文档https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb-indexing:只有在集合为空(不包含任何文档)时才能创建唯一索引。
因此,我清理了集合中的所有数据,但是我遇到了错误,错误信息为:
错误=13,详情='响应状态代码指示失败:禁止(403);子状态:0;ActivityId: xxx,原因:(消息:{"serializedCollection":"{"Errors":["唯一索引不能被修改。要更改唯一索引,请删除集合并创建一个新的。"]}", "serializedOffer": "", "serializedPartitionKeyRanges": [], "serializedPartitions": [], "collectionRemoteStorageSecurityIdentifier": "xxx", "collectionChildResourceNameLimitInBytes": -1, "collectionChildResourceContentLengthLimitInKB": -1, "uniqueIndexNameEncodingMode": 0, "uniqueIndexReIndexingState": 0} ActivityId: xxx,请求URI:/apps/xxx/xxx/partitions/xxx/replicas/xx,请求统计信息: 请求开始时间:2020-12-02T23:25:04.2104773Z,请求结束时间:2020-12-02T23:25:04.2204125Z,尝试的区域数:1 响应时间:2020-12-02T23:25:04.2204125Z,StoreResult:StorePhysicalAddress:rntbd://10.0.0.29:11000/apps/xxx/services/xx/partitions/xx/replicas/xx,LSN:41,GlobalCommittedLsn:41,PartitionKeyRangeId:,IsValid:True,StatusCode:403,SubStatusCode:0,RequestCharge:1.57,ItemLSN:-1,SessionToken:-1#41,UsingLocalLSN:False,TransportException:null,ResourceType:Collection,OperationType:Replace,SDK:Microsoft.Azure.Documents.Common/2.11.0,请参阅CosmosDiagnostics,Windows/10.0.17763 cosmos-netstandard-sdk/3.3.2);
我试图仅添加字段名称,但出现以下错误信息:
你有任何想法为什么会出现这些错误吗?
谢谢,
因此,我清理了集合中的所有数据,但是我遇到了错误,错误信息为:
错误=13,详情='响应状态代码指示失败:禁止(403);子状态:0;ActivityId: xxx,原因:(消息:{"serializedCollection":"{"Errors":["唯一索引不能被修改。要更改唯一索引,请删除集合并创建一个新的。"]}", "serializedOffer": "", "serializedPartitionKeyRanges": [], "serializedPartitions": [], "collectionRemoteStorageSecurityIdentifier": "xxx", "collectionChildResourceNameLimitInBytes": -1, "collectionChildResourceContentLengthLimitInKB": -1, "uniqueIndexNameEncodingMode": 0, "uniqueIndexReIndexingState": 0} ActivityId: xxx,请求URI:/apps/xxx/xxx/partitions/xxx/replicas/xx,请求统计信息: 请求开始时间:2020-12-02T23:25:04.2104773Z,请求结束时间:2020-12-02T23:25:04.2204125Z,尝试的区域数:1 响应时间:2020-12-02T23:25:04.2204125Z,StoreResult:StorePhysicalAddress:rntbd://10.0.0.29:11000/apps/xxx/services/xx/partitions/xx/replicas/xx,LSN:41,GlobalCommittedLsn:41,PartitionKeyRangeId:,IsValid:True,StatusCode:403,SubStatusCode:0,RequestCharge:1.57,ItemLSN:-1,SessionToken:-1#41,UsingLocalLSN:False,TransportException:null,ResourceType:Collection,OperationType:Replace,SDK:Microsoft.Azure.Documents.Common/2.11.0,请参阅CosmosDiagnostics,Windows/10.0.17763 cosmos-netstandard-sdk/3.3.2);
我试图仅添加字段名称,但出现以下错误信息:
当集合包含文档时无法创建唯一索引
我们正在使用支持Mongodb 3.6的CosomosDB。我使用了以下命令: db.CollectName.createIndex({"fieldname" : 1},{"unique" : true })你有任何想法为什么会出现这些错误吗?
谢谢,
db.getCollectionInfos({name:"CollectName"})
输出结果:
- user12582392