Search code examples
mongodbazureazure-cosmosdbazure-cosmosdb-mongoapi

Azure CosmosDb with mongo error - "MongoError: query in command must target a single shard key"


I have a cosmosdb database with Sharedkey. When my service run, it remove all documents by sharedkey field and insert the next. But during tests I had duplicateds inserts without errors notifys.I't have permission to directly delete the collection. This's customer envirronment and has process to change database. I'd like to remove all collection documents. But has duplicated SharedKey fields and throw this error message:

MongoError: query in command must target a single shard key

When list by shared key enter image description here

When try to remove by shared key enter image description here

Hey friends somebody can "give me a hand"?

Obrigado!!!


Solution

  • It was a bug. To fix i had to remove all data and move to another collection with once sharedkey.

    The best solutions was to change to Atlas MongoDb 😋