我有这个示例 mongodb 文档-
{
_id: 5db85ee97d9fb13ead4fc54c
applId: 5d48f34f7d9fb10ce171f905
fileId: "dd386cf7-4139-45c2-9853-cbb126621b51"
job: Object
country: "US"
fullName: "abcd xyz"
htmlWordCount: 2766
textWordCount: 1867
rchilliTextWordCount: 2840
deleted: 0
dateEntered: 2019-10-29 15:46:49.237
dateModified: 2019-10-29 15:46:49.237
}
我想在指南针中构建一个查询,以便在输出中有以下字段 -
{
_id: 5db85ee97d9fb13ead4fc54c
country: "US"
fullName: "abcd xyz"
htmlWordCount: 2766
textWordCount: 1867
rchilliTextWordCount: 2840
winner: "rchilliTextWordCount"
}
请注意,它有一个名为“winner”的新字段,它始终返回具有最大字数的列(共 3"htmlWordCount", "textWordCount", "rchilliTextWordCount"
列)。这个新列"winner"
将在运行时查询时生成。此查询也被过滤country = "US"
。
我如何在 MongoDB Compass 中执行此操作,或者聚合管道应该是什么样子?