[COMPASS-4967] Create view from Aggregation contains no data Created: 21/Jul/21  Updated: 25/Aug/23  Resolved: 04/Aug/21

Status: Closed
Project: Compass
Component/s: Compass
Affects Version/s: 1.28.1
Fix Version/s: No version

Type: Bug Priority: Major - P3
Reporter: Irene Xie Assignee: Unassigned
Resolution: Declined Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Microsoft Azure CosmosDB (Mongo API)


Documentation Changes: Not Needed

 Description   

Problem Statement/Rationale

I am using Azure CosmosDB (mongo API 3.6) as the backend database for my application. When I am using MongoDB Compass to create a view after building the aggregation pipeline, the view contains no data. The same test on my local mongo database doesn't have this issue so I am thinking it might be a bug when create the view from CosmosDB (mongo API 3.6). 

Steps to Reproduce

Create a collection from CosmosDB (mongo API 3.6).  Insert the data to this new collection with a datetime field. Then on the aggregation tab, build a stage with $match and have the datetime in a range ,  for example, using the following code {
'datetime': { $lt: ISODate("2021-02-01T00:00:00.000Z"), $gte: ISODate("2021-01-01T00:00:00.000Z") }
}

Make sure you have the data after applying the aggregation. Then save this as a view. After saving the view, the view should contain the resultset. But when I used the same method on CosmosDB (Mongo API 3.6), I am not seeing any data from the view. 

Expected Results

What do you expect to happen?

Actual Results

What do you observe is happening?

Additional Notes

Any additional information that may be useful to include.



 Comments   
Comment by Massimiliano Marcon [ 04/Aug/21 ]

irene.xie@hhs.texas.gov as you suggested, this is a CosmosDB-specific problem. It's not a bug in Compass, it's just that CosmosDB does not seem to support the creation of views. The createView command isn't listed in their list of commands that are supported: https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-feature-support-36. See also a related SO thread: https://stackoverflow.com/questions/55060005/is-it-possible-to-use-mongodb-views-with-azure-cosmosdb.

Have you considered using MongoDB Atlas instead? CosmosDB only supports a limited subset of the MongoDB functionality (I believe 3/4 of what MongoDB offers isn't available in CosmosDB) so developing locally against MongoDB and then using CosmosDB for production might result in a back and forth of things that work locally but don't work once the code is deployed. Happy to chat more about this if you'd like.

Generated at Wed Feb 07 22:37:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.