Spring-Data annotations on CosmosDB with MongoDB API don't work

Tufekcic, Dino 16 Reputation points
2021-04-20T20:29:50.547+00:00

Indexing annotations in my Spring Boot application don't work on my Azure CosmosDB with MongoDB API. Using the same annotations directly with a local instance of MongoDB works as expected. This issue was referenced in this post https://learn.microsoft.com/en-us/answers/questions/258032/the-index-path-corresponding-to-the-specified-orde.html but no feedback was offered from MS.

Could someone from MS please respond to the following questions?

  1. Is this is an issue with CosmosDB with Mongo API?
  2. What is the expected time frame for a fix?
  3. Are there any work-arounds other than manually creating indexes?
  4. Possibly unrelated, but creating a composite index from a mongo shell on a CosmosDB instance fails with an 'unsupported' error globaldb:PRIMARY> db.feed.createIndex({"_id.reportDate": -1, "_id.ownerUpn": 1}) { "ok" : 0, "errmsg" : "Unique and compound indexes do not support nested paths.", "code" : 115, "codeName" : "CommandNotSupported" }
    Is this something that will be supported soon? It works with native MongoDB

Thanks
Dino

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,643 questions
{count} votes

1 answer

Sort by: Most helpful
  1. kobulloc-MSFT 26,336 Reputation points Microsoft Employee
    2021-04-21T02:55:12.607+00:00

    In response to question 4: "Unique and compound indexes do not support nested paths.", the Azure Cosmos DB Team has said recently (March 9th, 2021) that this is a feature that is currently being worked on. There should be an update once they enter preview or GA:

    https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/40015003-unique-index-in-nested-documents-or-arrays


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.