无法使用 Azure UI 将数据上传到 Cosmos

问题描述 投票:0回答:1

我想将数据上传到cosmos DB(NoSQL API)。 这是我的表分区键逻辑

分区键:/x_id/位置/名称 唯一键:[/source, /type]

我要上传的JSON文件是

[
  {
    "x_id": "1",
    "type": "ROLL",
    "location": "10",
    "source": "A",
    "event_name": "B"
  },
  {
    "x_id": "2",
    "type": "ROLL",
    "location": "11",
    "source": "C",
    "event_name": "D"
  }
]

保存数据时出现以下错误

Error bulk creating items for container table_name:
 Cannot use the 'in' operator to search for 'location' in 1

但是,当我将单个项目添加到同一个容器时,它工作正常,但是当进行批量上传时,它开始出现上述错误。

用于批量上传的选项:

Upload Item

错误:

有人可以帮忙吗?

json database nosql azure-cosmosdb bulkinsert
1个回答
0
投票
  • 为了在cosmos db中创建分层分区键,
    /x_id/location/name
    单击
     Add hierarchical partition key
    按顺序添加每个键。由于共享的示例文档中没有名为
    name
    的列,因此我将其替换为
    event_name

enter image description here

  • 如上图所示创建分区密钥后,项目已上传,没有任何错误。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.