Tôi đã tìm thấy giải pháp. Tôi cần thay đổi and toán tử cho Projections.fields Tôi vẫn không biết tại sao. Có lẽ ai đó khác có thể giải thích về điều đó.
Vì vậy, truy vấn đang hoạt động trông giống như sau:
collectionName.aggregate(
Arrays.asList(
group(fields(eq("year", "$year"),
eq("month", "$month"),
eq("day", "$day"),
eq("prodName", "$prodName"),
eq("actionName", "$actionName")),
sum("actionCount", 1))
);