I tried the query below but for some reason I get a Unknown server error occurred when processing this request. I am a bit new to mongodb but when reading the documentation for Mongodb shell and CosmosDB, all the operators listed seem supported and this look syntactically correct.
db.getCollection('transactions').aggregate(
[
{
$match:{
bdr_date: 20181031,
make: { $exists: false },
shard_key: '1249_2018-10',
time: { $gt: 2344 }
}
},
{
$group: {
total_sales: {
$sum: {
$multiply: [
"$sales",
"$units"
]
}
}
}
}
]
)
My CosmosDB uses MongoAPI and contains one collection named transactions with documents that have many keys but here are the important ones:
{
"bdr_date" : INT(32),
"time" : INT(32),
"sales" : Double,
"units" : INT(32),
"shard_key" : String
}
There is also a key called { "make": INT(32) } in some documents where we had a script that filled data holes. I only wanted documents with real data so I filtered out documents with the "make" key. bdr_date is in yyyymmdd format and time is in HHMM format.
The error code doesn't really say much else except for the unknown server error exception so I'm pretty stumped on what exactly I am doing wrong. Is there something simple that I am missing?
If you need more information, I'll do my best to accommodate. I appreciate the help!