I was looking to use cosmosdb to store time series data laid out in a document-centric design. Using the official mongodb driver I tried to write some simple aggregation statements; however, I received errors stating that $unwind and $group were not supported. Given that cosmosdb was touted as a drop-in replacement to mongodb did I miss a step or is aggregation not a supported feature.
retrieve.Aggregate().Unwind(i => i.Observations).Group(new BsonDocument {
{"_id", "$Observations.Success"},
{"avg", new BsonDocument{
{"$avg", "$Observations.Duration"}
}}
}).ToList();
As of November 2017, Cosmos DB's MongoDB API now supports aggregation pipeline, including all of the pipeline stages identified in your original question ($unwind
, $group
).
Specifics of supported features are listed here.