DocumentDB REST API: x-ms-documentdb-partitionkey 无效
DocumentDB REST API: x-ms-documentdb-partitionkey is invalid
我试图使用 REST API 从 DocumentDB 获取文档。我正在使用分区 Collection,因此需要添加 "x-ms-documentdb-partitionkey" header。如果我添加这个,我得到 "Partition key abc is invalid"。我在文档中找不到期望密钥采用特定格式的任何地方,但仅提供预期的字符串值是行不通的。有人知道预期的格式吗?
分区集合的分区键实际上是 DocumentDB 中 属性 的路径。因此,您需要按以下格式指定它:
/{path to property name} e.g. /department
来自Partitioning and scaling in Azure DocumentDB
:
You must pick a JSON property name that has a wide range of values and
is likely to have evenly distributed access patterns. The partition
key is specified as a JSON path, e.g. /department represents the
property department.
link 中还列出了更多示例。
分区键必须指定为数组(具有单个元素)。例如:
x-ms-documentdb-partitionkey: [ "abc" ]
我试图使用 REST API 从 DocumentDB 获取文档。我正在使用分区 Collection,因此需要添加 "x-ms-documentdb-partitionkey" header。如果我添加这个,我得到 "Partition key abc is invalid"。我在文档中找不到期望密钥采用特定格式的任何地方,但仅提供预期的字符串值是行不通的。有人知道预期的格式吗?
分区集合的分区键实际上是 DocumentDB 中 属性 的路径。因此,您需要按以下格式指定它:
/{path to property name} e.g. /department
来自Partitioning and scaling in Azure DocumentDB
:
You must pick a JSON property name that has a wide range of values and is likely to have evenly distributed access patterns. The partition key is specified as a JSON path, e.g. /department represents the property department.
link 中还列出了更多示例。
分区键必须指定为数组(具有单个元素)。例如:
x-ms-documentdb-partitionkey: [ "abc" ]