我真的不知道该怎么做。基本上在我的文档中,我有一个比率,我想找到计算比率低于某个值的文档。计算费率如下:
if (rate < 20) {
calculated_rate = rate * 1.25;
} else {
calculated_rate = rate + 5;
}
aggregate(
[
{
"$addFields" : {
"calculated_rate" : {
"$cond" : [
{
"$lt" : [
"$AreasServedRateAndConditions.CGHourlyRate",
20.0
]
},
{
"$multiply" : [
"$AreasServedRateAndConditions.CGHourlyRate",
1.25
]
},
{
"$add" : [
"$AreasServedRateAndConditions.CGHourlyRate",
5.0
]
}
]
}
}
},
{
"$match" : {
"$and" : [
{
"calculated_rate" : {
"$lte" : 25.0
}
}
]
}
}
],
{
"allowDiskUse" : false
}
);