- I've set up an Azure Cosmos DB that exposes the MongoDB API.
- I connect to the DB with the mongo shell.
- I create a new db
sample
withuse sample
. - I create a simple collection
sample
withdb.sample.insert({})
- I then try to run the following query:
db.sample.findOneAndUpdate({ foo: {"$eq":1}},{ "$set": { "bar":1}},{"sort": { "foo": 1, "bar": 1 }})
When I run this against a normal MongoDB 3.2.0 instance, the query completes successfully (and matches 0 results). However, on CosmosDB, the following stacktrace is produced:
2019-01-31T13:46:49.740+0100 E QUERY [thread1] Error: findAndModifyFailed failed: {
"_t" : "OKMongoResponse",
"ok" : 0,
"code" : 2,
"errmsg" : "Message: {\"Errors\":[\"Encountered exception while executing function. Exception = Error: {\\\"Errors\\\":[\\\"The order by query does not have a corresponding composite index that it can be served from.\\\"]}\\r\\nStack trace: Error: {\\\"Errors\\\":[\\\"The order by query does not have a corresponding composite index that it can be served from.\\\"]}\\n at queryCallback (__.sys.commonUpdate_BsonSchema.js:3835:26)\\n at Anonymous function (__.sys.commonUpdate_BsonSchema.js:607:29)\"]}\r\nActivityId: ff7b4476-0000-0000-0000-000000000000, Request URI: /apps/c2de8f1c-dee1-4b6c-8543-479a695c3bb2/services/12da6069-653a-45be-bfa1-4394a0798877/partitions/2814e64e-3d06-4705-a346-cbbfc822a49a/replicas/131934057017796979p/, RequestStats: \r\nRequestStartTime: 2019-01-31T12:46:49.6846466Z, Number of regions attempted: 1\r\n, SDK: Microsoft.Azure.Documents.Common/2.1.0.0",
"$err" : "Message: {\"Errors\":[\"Encountered exception while executing function. Exception = Error: {\\\"Errors\\\":[\\\"The order by query does not have a corresponding composite index that it can be served from.\\\"]}\\r\\nStack trace: Error: {\\\"Errors\\\":[\\\"The order by query does not have a corresponding composite index that it can be served from.\\\"]}\\n at queryCallback (__.sys.commonUpdate_BsonSchema.js:3835:26)\\n at Anonymous function (__.sys.commonUpdate_BsonSchema.js:607:29)\"]}\r\nActivityId: ff7b4476-0000-0000-0000-000000000000, Request URI: /apps/c2de8f1c-dee1-4b6c-8543-479a695c3bb2/services/12da6069-653a-45be-bfa1-4394a0798877/partitions/2814e64e-3d06-4705-a346-cbbfc822a49a/replicas/131934057017796979p/, RequestStats: \r\nRequestStartTime: 2019-01-31T12:46:49.6846466Z, Number of regions attempted: 1\r\n, SDK: Microsoft.Azure.Documents.Common/2.1.0.0"
} :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DBCollection.prototype.findAndModify@src/mongo/shell/collection.js:757:1
DBCollection.prototype.findOneAndUpdate@src/mongo/shell/crud_api.js:785:12
@(shell):1:1
Are there some additional query restrictions that exist in CosmosDB that don't exist in normal MongoDB instances? Is this just a CosmosDB bug? What is the appropreate way to go around reporting such bugs?