现在,当我们从Python调用时,我们在选项中设置'EnableCrossPartitionQuery=' True' . 它仍然显示错误 . pydocumentdb.errors.HTTPFailure: Status code: 400 {"code":"BadRequest","message":"PartitionKey value must be supplied for this operation.
这是我们使用pydocumentdb进行的python调用 .
def exec_sp(member_number): client = document_client.DocumentClient(statics.cosmosEndpoint, {'masterKey': statics.cosmosMasterkey}) query = {'query': "select * from c where c.type='Transaction'"} options = {} options['enableCrossPartitionQuery'] = True coll_path = 'dbs/database/colls/samplecollection' sp_path = coll_path + '/sprocs/' + 'bulkdelete' result = client.ExecuteStoredProcedure(sp_path, query, options=options)
2 回答
你可以参考上面提到here的描述 .
当然,如果您的集合已被分区,则还需要在操作集合或文档时提供分区键 . 来自here的更多细节 .
所以,根据你不了解分区键的情况,我建议你在执行删除时在
FeedOptions
中将EnableCrossPartitionQuery
设置为true
. (有性能瓶颈)希望它能帮到你 .
现在,当我们从Python调用时,我们在选项中设置'EnableCrossPartitionQuery=' True' . 它仍然显示错误 .
pydocumentdb.errors.HTTPFailure: Status code: 400 {"code":"BadRequest","message":"PartitionKey value must be supplied for this operation.
这是我们使用pydocumentdb进行的python调用 .
def exec_sp(member_number): client = document_client.DocumentClient(statics.cosmosEndpoint, {'masterKey': statics.cosmosMasterkey}) query = {'query': "select * from c where c.type='Transaction'"} options = {} options['enableCrossPartitionQuery'] = True coll_path = 'dbs/database/colls/samplecollection' sp_path = coll_path + '/sprocs/' + 'bulkdelete' result = client.ExecuteStoredProcedure(sp_path, query, options=options)