Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Azure Cosmos DB,删除ID(绝对存在)_Python_Azure_Azure Cosmosdb - Fatal编程技术网

Python Azure Cosmos DB,删除ID(绝对存在)

Python Azure Cosmos DB,删除ID(绝对存在),python,azure,azure-cosmosdb,Python,Azure,Azure Cosmosdb,这可能是一个非常简单和愚蠢的错误,但我不确定这是如何失败的。我已经使用了教程。如何查询数据库,然后使用这些id删除,然后它们就不存在了 周末到来之前有人能帮忙吗?谢谢,努力想知道这是怎么失败的 错误: azure.cosmos.errors.HTTPFailure: Status code: 404 {"code":"NotFound","message":"Entity with the specified id does not exist in the system., \r\nReque

这可能是一个非常简单和愚蠢的错误,但我不确定这是如何失败的。我已经使用了教程。如何查询数据库,然后使用这些
id
删除,然后它们就不存在了

周末到来之前有人能帮忙吗?谢谢,努力想知道这是怎么失败的

错误:

azure.cosmos.errors.HTTPFailure: Status code: 404
{"code":"NotFound","message":"Entity with the specified id does not exist in the system., \r\nRequestStartTime: 2020-02-07T17:08:48.1413131Z,
RequestEndTime: 2020-02-07T17:08:48.1413131Z, 
Number of regions attempted:1\r\nResponseTime: 2020-02-07T17:08:48.1413131Z,
StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-northeurope1-fd24.documents.azure.com:14363/apps/dedf1644-3129-4bd1-9eaa-8efc450341c4/services/956a2aa9-0cad-451f-a172-3f3c7d8353ef/partitions/bac75b40-384a-4019-a973-d2e85ada9c87/replicas/132248272332111641p/,
LSN: 79, GlobalCommittedLsn: 79, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 404,
SubStatusCode: 0, RequestCharge: 1.24, ItemLSN: -1, SessionToken: 0#79#13=-1,
UsingLocalLSN: False, TransportException: null, ResourceType: Document,
OperationType: Delete\r\n, Microsoft.Azure.Documents.Common/2.9.2"}
这是我的密码

def get_images_to_check(database_id, container_id):
    images = client.QueryItems("dbs/" + database_id + "/colls/" + container_id,
                                        {
                                                'query': 'SELECT * FROM c r WHERE r.manually_reviewed=@manrev',
                                                'parameters': [
                                                    {'name': '@manrev', 'value': False}
                                                ]
                                        },
                                        {'enableCrossPartitionQuery': True})
    return list(images)

def delete_data(database_id, container_id, data):
    for item in data:
        print(item['id'])
        client.DeleteItem("dbs/" + database_id + "/colls/" + container_id + "/docs/" + item['id'], {'partitionKey': 'class'})

database_id = 'ModelData'
container_id = 'ImagePredictions'
container_id = 'IncorrectPredictions'
images_to_check = get_images_to_check(database_id, container_id)
delete_data(database_id, container_id, images_to_check)```

问题很可能是文档的
id
PartitionKey
值不匹配。文档在集合中通过其id和PartitionKey值的组合进行唯一标识


因此,为了删除文档,您需要为文档的id及其分区键值指定正确的值。

在调用
client.DeleteItem()
中指定分区键值时,您选择:

{'partitionKey': 'class'}
DeleteItem()
的额外参数应该指定分区键的值

根据您的注释,
/class
是您的分区键。所以我相信,如果你把参数改成:

{'partitionKey': 'value-of-partition-key'}

这很有希望奏效。

分区键的路径是什么?是
/class
?或者分区键是其他值,而值是
class
?请编辑您的问题,以提供分区键是哪个属性的详细信息。是的,我的分区键路径是
/class
值是其他值。我假定给定的注释是
class
是错误的条目,不是分区键,而是分区键的值。谢谢你的帮助!