"Insert error." for Mongo insertMany operation

Charlie L 21 Reputation points
2020-07-20T22:49:11.29+00:00

When performing a Mongo insertMany operation with ordered=false, Cosmos responds in some cases with the following error:

BulkWriteError{index=0, code=2, message='Error=2, Details='Insert error.', details={}}  

The troubleshooting documentation provides the following explanation of error code 2: "The query requests a sort on a field that is not indexed."

However, I encountered this error code when performing a bulk insert, not a sorted query. What can this error code indicate when returned from an insertMany operation?

Thank you

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,632 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Navtej Singh Saini 4,226 Reputation points Microsoft Employee
    2020-07-21T01:05:34.257+00:00

    @Charlie L

    Please confirm if this bulk insert is part of change of Wire Protocol for Azure Cosmos DB for Mongo DB API from 3.2 to 3.6

    We have seen this previously where this was done and the reason was the indexing works differently in wire protocol 3.2 and 3.6. In 3.2 indexing is applied on the all the fields but in 3.6 accounts the indexing Is applied only on _id field and it depends on the end user to enable indexing on other fields.

    Please check the Mongo Index document and MongoDB3.6 feature support document.

    If you have compound indexing you may to move them separately on different fields and then test.

    If above is not the case, please get back to us and we will try to help further.

    Thanks
    Navtej S


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.