json - Azure + Cosmos DB :

标签 json azure azure-cosmosdb

我使用 Azure 和 Cosmos DB 来存储一些信息,但我创建的新集合存在一些问题。

我总是出现这样的错误消息:

Failed to update document 5b83e5297dfa952bb4036fa6: {"code":400,"body":"Command update failed: query in command must target a single shard key."}

集合名称是“item”,我尝试存储一些图像 URL。所以,我首先尝试添加以下文档

{
    "_id" : ObjectId("5b83e5297dfa952bb4036fa6"),
    "imageURL" : "https://www.tendance-parfums.com/media/resized/460/600/baseline-1/bgcolor-255-255-255/constrainonly-1/defaultimage-/keepaspectratio-1/keepframe-/mode-outer_resize/media/catalog/product/c/h/chanel-n5-eau-de-parfum-vaporisateur-y_2.jpg"
}

请注意,_id 是自动创建的。

所以,我不知道为什么Azure门户总是给出一些错误!

一些细节,集合使用默认参数(无限大小),我使用 imageURL 作为分片键,15000 作为吞吐量,item 作为集合 ID。

有什么想法吗?

PS:另一个问题是它在创建集合时正在寻找shard key,但目前我只有这个字段imageURL,但我没有确定合适吗?

最佳答案

我找到了一种方法来修复它,看来分片键不能是 URL,所以我使用了另一个复杂的分片键并且它有效!!!

关于json - Azure + Cosmos DB :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52038904/

相关文章:

node.js - 为什么我无法在 React 代码中使用 @azure/web-pubsub Node 包?

azure - 使用持久的 Azure Functions 将文档写入 Cosmos DB 时面临的问题

c# - Azure Function 引发 Azure Document Client 构造函数异常(在测试工具中工作)

c# - 从 Controller 发送颜色十六进制到 View 而不带引号变成“?

javascript - vue-stripe-elements - 一个文件的配置

azure - 当另一个属性与某个提供的值匹配时有条件地更新一个顶点属性

php - Azure 通知中心 - 401 MissingToken : The authorization header was not found

mongodb - Azure cosmos DB 3.6 Mongo 不支持具有嵌入字段的复合索引

java - 如何更改单值java对象的JSON表示?

json - Powershell - 解析不一致的 Json 数据