更新时间:2023-11-23 08:21:10
我找到了解决方案.我需要将 and
运算符更改为 Projections.fields
运算符.我仍然不知道为什么.也许其他人可以详细说明这一点.
I found the solution.
I needed to change the and
operator to a Projections.fields
operator.
I still don't know why. Maybe someon else can elaborate about that.
所以工作查询看起来像这样:
So the working query looks like this:
collectionName.aggregate(
Arrays.asList(
group(fields(eq("year", "$year"),
eq("month", "$month"),
eq("day", "$day"),
eq("prodName", "$prodName"),
eq("actionName", "$actionName")),
sum("actionCount", 1))
);