简体   繁体   中英

Azure + Cosmos DB :

I use Azure and Cosmos DB to store some information, but I have some issues with a new collection I have created.

I always go such kind of error message :

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

The collection name is "item" and I try to store some images URLs. So, I first try to add the following document

{
    "_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"
}

Notice that the _id is created automatically.

So, I don't know why the Azure portal is always giving some errors!

Some details, the collection use the default parameters (Unlimited size), I use imageURL as shard key, 15000 as throughput and item as collection id.

Any idea?

PS: Another question is that it is looking for a shard key when creating the collection, but for now I only have this field imageURL , but I'm not sure it is suitable?

我找到了一种解决方法,似乎分片键不能是URL,所以我使用了另一个复杂的键,它可以工作!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM