We’re using Azure Cosmos DB for MongoDB. When running a query we’re receiving an incorrect _id in the response.
hi @Brian_Murphy ,
Can you share query and few of your BsonDocuemnt from you database to understand the query result.
Here is the code snippet.
var tempFromDate = BsonDateTime.Create(fromDate);
var tempfilter = Builders<BsonDocument>.Filter.Gte("CreatedDateTime", tempFromDate);
var tempprojection = Builders<BsonDocument>.Projection.Include("CreatedDateTime").Include("DecisionToken");
var tempDocList = collection.Find<BsonDocument>(tempfilter).Project(tempprojection).ToList();
I can’t actually share the BsonDocuments since it’s an underwriting decision journal. Overall we’re running a query to return a list of some basic data including the _id. The end user can then select a specific journal and we will then use the _id to fetch the record from the database. Unfortunately the _id isn’t the same and therefore we can’t return the record they are looking for.
The values of _id do not magically change even if you are using CosmosDB rather than the real MongoDB.
You are doing find() so your criteria might match and return more than 1 document. I think you are simply looking at the wrong documents.
And since you do not sort the orders in one application/view vs the other might differ.
In addition to what @steevej mentioned, CosmosDB is a Microsoft product and is semi-compatible with a genuine MongoDB server. Hence, I cannot comment on how it works, or even know why it’s not behaving like a genuine MongoDB server.
At the moment of this writing, CosmosDB currently passes only 33.51% of MongoDB server tests, so I would encourage you to engage CosmosDB support regarding this issue.
Best regards
Kevin
I appreciate all of the feedback! We’ll open a ticket with Microsoft.