Cosmos DB-具有自定义分区键的批量导入(单个分区集合) [英] Cosmos DB - Bulk Import (single partition collections) with customized partition key

查看:110
本文介绍了Cosmos DB-具有自定义分区键的批量导入(单个分区集合)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次尝试使用单列名或列名的组合定义分区键时,我尝试使用数据迁移工具将一些数据从JSON文件迁移到Cosmos DB.迁移后我得到了未定义的分区键,如何解决此问题?

I am trying to migrate some data from a JSON file to Cosmos DB using Data Migration Tool, when I tried to define the partition key with either single or a combination of my column name, every time I am getting undefined partition key after migration, how could I correct this issue?

请注意,这里我必须使用批量导入(单个分区集合)选项,因为我需要为

Note here I'll have to use Bulk import (single partition collections) options, because I need to execute my customized stored procedure for nested array import, I cannot use sequential record import as I know the same partition function works very well there.

所以在这里,我将分区键设置为"/item/vid":

So here I am setting my partition key to be "/item/vid":

迁移后,我的收藏集在其中显示"_partitionKey"而不是"/item/vid":

After migration, my collection shows "_partitionKey" instead of "/item/vid" there:

推荐答案

如果您将批量导入"与迁移工具一起使用,则分区键设置不仅适用于收集方案.请参阅以下

If you use Bulk import with migration tool, the partition key setting is for more than collection scenario.Please see the statement in this link:

当您导入多个集合时,导入工具支持 基于散列的分片.在这种情况下,指定文档属性 您希望用作分区密钥. (如果分区键留为空白, 文档在目标集合中随机分片.)

When you import to more than one collection, the import tool supports hash-based sharding. In this scenario, specify the document property you wish to use as the Partition Key. (If Partition Key is left blank, documents are sharded randomly across the target collections.)

回到您的要求,您可以使用顺序记录导入.

Back to your requirement,you could use Sequential Record Import.

您需要先创建集合并将分区键设置为/item/vid.

You need to create collection first and set the partition key as /item/vid.

我的测试json文件:

My test json file:

结果:

Result:

这篇关于Cosmos DB-具有自定义分区键的批量导入(单个分区集合)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆