Search code examples
azureazure-cosmosdbazure-cosmosdb-mongoapi

Issues with azure cosmosDB 3.6 on field sort operation with index exceeded maximum number


Issues popup using Azure cosmosDB version 3.6 with mongodb API enabled, basically we want to sort on a particular field in a collection but we are getting error:

 Error: error: {
    "ok" : 0,
    "errmsg" : "Error=2, Details='Microsoft.Azure.Cosmos.Query.Core.Monads.ExceptionWithStackTraceException: TryCatch resulted in an exception. ---> Microsoft.Azure.Cosmos.Query.Core.Monads.ExceptionWithStackTraceException: TryCatch resulted in an exception. ---> Microsoft.Azure.Cosmos.Query.Core.Monads.ExceptionWithStackTraceException: TryCatch resulted in an exception. ... ...
    "code" : 2,
    "codeName" : "BadValue"
}

However it could be a easier fix that we found out that it went smooth with other field on sort operation if a index is given, but when we were trying to add the index to current collection on this specific field another issue popup which kind of brought us the a dead-end.

{
    "ok" : 0.0,
    "errmsg" : "Exceeded maximum number of indexes",
    "code" : 67,
    "codeName" : "CannotCreateIndex"
}

It's really confusing that by using cosmosdb with MongoDB API on version 3.2 previously we got the official support from Microsoft team saying that on version 3.2 indices are created automatically and thus we were having such issue with indexes exceeds the limit alike issues. But should be gone in version 3.6 which is why we made the decision to migrate all the existing system onto Azure cloud using cosmosDB.

In this particular collection which we currently trying to perform the createIndexoperation has only 17 indexes existing, confused about what is this limit anyway regarding the "Exceeded maximum number of indexes" error.


Solution

  • Looks like you are hitting the soft limit on the maximum indexes limit, You can file a support request to increase the maximum indexes limit for your account.