我使用了词素对MongoDB进行数据聚合。但我需要四舍五入汇总管道投影数据。我的代码是
aggregationPipeline.project(
Projection.projection("_id").suppress(),
Projection.projection("query", "_id.query"),
Projection.projection("clicks", "clicks"),
Projection.projection("impressions", "impressions"),
Projection.projection("ctr", "ctr"),
Projection.projection("position", "position")
);
我的输出是
{
"query": "google",
"clicks": 5,
"impressions": 16,
"ctr": 0.19375,
"position": 3.39375,
},
但我希望
{
"query": "google",
"clicks": 5,
"impressions": 16,
"ctr": 0.19,
"position": 3.39,
},