【发布时间】:2017-06-04 12:17:57
【问题描述】:
我正在尝试在最新的 mongo 3.4.1 服务器和 3.4.1 shell 中执行以下查询。
db.dealer.aggregate(
[
{$match:{salesAreaId:{$in:[ObjectId("5858d03ec5109a098c854802")]}}},
{$lookup:{
from:"outstanding",
localField:"_id",
foreignField:"dealer_id",
as:"outstandings"
}},
{$filter:{
input:"$outstandings",
as:"outstandings",
cond:{
$is:{"$$outstandings.finalized":false}
}
}}
]
)
但它说
Error: command failed: {
"ok" : 0,
"errmsg" : "Unrecognized pipeline stage name: '$filter'",
"code" : 40324,
"codeName" : "Location40324"
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:23:13
doassert@src/mongo/shell/assert.js:13:14
assert.commandWorked@src/mongo/shell/assert.js:266:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
@(shell):1:1
根据documentation $filter 从 v3.2 开始支持。
任何帮助。
【问题讨论】:
-
$filter 应该被包裹在 $project 管道阶段
-
谢谢。没错
标签: mongodb