我可以使用“$”运算符引用 MongoDB 聚合管道中属性的各个值的值。但是,我如何访问(参考)整个文档?
更新:提供一个示例来解释场景。
这是我正在尝试做的一个例子。我有一系列推文。每条推文都有一个成员“集群”,这表明特定推文属于哪个集群。
{
"_id" : "5803519429097792069",
"text" : "The following vehicles/owners have been prosecuted by issuing notice on the basis of photographs on dated... http://t.co/iic1Nn85W5",
"oldestts" : "2013-02-28 16:11:32.0",
"firstTweetTime" : "4 hours ",
"id" : "307161122191065089",
"isLoc" : true,
"powertweet" : true,
"city" : "new+delhi",
"latestts" : "2013-02-28 16:35:05.0",
"no" : 0,
"ts" : 1362081807.9693,
"clusters" : [
{
"participationCoeff" : 1,
"clusterID" : "5803519429097792069"
}
],
"username" : "dtptraffic",
"verbSet" : [
"date",
"follow",
"prosecute",
"have",
"be"
],
"timestamp" : "4 hours ",
"entitySet" : [ ],
"subCats" : {
"Generic" : [ ]
},
"lang" : "en",
"fns" : 18.35967,
"url" : "url|109|131|http://fb.me/2CeaI7Vtr",
"cat" : [
"Generic"
],
"order" : 7
}
由于我的收藏中有几十万条推文,我想按“clusters.clusterID”对所有推文进行分组。基本上,我想编写如下查询:
db.tweets.aggregate (
{ $group : { _id : '$clusters.clusterID', 'members' : {$addToSet : <????> } } }
)
我想访问当前正在处理的文档并在上面查询中引用它。有谁知道该怎么做?