Hello guys.I have a problem in sorting by multiple fields .
My query is this:
mydb1.mongodbbucketright.aggregate([
{
"$match": {
"first": {"$gte": datetime.strptime("2010-01-01 00:00:00", "%Y-%m-%d %H:%M:%S"),
"$lte" :datetime.strptime("2020-12-31 00:55:00", "%Y-%m-%d %H:%M:%S")}
}
},
{ "$unwind": "$samples" },
{
"$group": {
"_id":{
"date": {"$dateToString": { "format": "%Y-%m-%d ", "date": "$first" }},
"id13":"$samples.id13"
},
"avg_id9": {
"$avg": "$samples.id9"
}
}
},
{
"$project": {
"_id": 0,
"day":"$_id.date",
"avg_id9":1,
"id1313":"$_id.id13"
}
},
{"$sort": {"day": -1,"id1313":1}}
])
When i sort only with day
everything works fine,but when i add the second field to sort
the output gives me this message Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting.
What should i do?
Thanks in advance!