0
votes

Have data over Azure cosmos DB. While sorting over a column by following query: db.getCollection('xyz').find({}).sort({'created_at':-1,'_id':-1}).limit(10) getting following error: Note: have masked ActivityID pymongo.errors.OperationFailure: Error=2, Details='Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId:xyz; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId:xyz; Reason: (Response status code does not indicate success: BadRequest (400); Substatus: 0; ActivityId: xyz; Reason: (Message: {"Errors":["The index path corresponding to the specified order-by item is excluded."]}

1
Looks like you just need to add the column you are sorting on into your index. - Mark Brown
It did tried that, and even its recommended in following link: gitmemory.com/issue/telefonicaid/fiware-orion/3797/802057436 but no luck - SushantPatade

1 Answers

0
votes

As per the error and the reason behind the Bad request that it states : The index path corresponding to the specified order-by item is excluded.Hence, you have to add an matching index or a composite index for the sort by query being attempted.

Azure Cosmos DB has an wire protocol version 4.0, 3.0 and legacy support for version 3.2 as Azure Cosmos DB does not host the MongoDB engine. So the possibilities of these errors are only found in Azure Cosmos DB's API for MongoDB

Hence, would request you to refer this for more detailed information: Common errors and solutions