Reputation: 1898
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?
Upvotes: 1
Views: 355
Reputation: 1898
I have find a way to fix it, it seems the shard key cannot be an URL, so I use a another complex one and it work !!!
Upvotes: 2