MongoDB:InMatchExpression等式不能不确定

时间:2018-12-07 16:58:27

标签: mongodb

我有以下查询:db.Artworks.aggregate( [{ $lookup : { from : "Artists", localField : "Artist", foreignField : "_id", as : "Artist"} }, {$unwind:"$Artist"},{$project: {"_id":0,"Artist.DisplayName":1}}]) 可以按照我期望的那样输出:

{ "Artist" : { "DisplayName" : "Otto Wagner" } }
{ "Artist" : { "DisplayName" : "Christian de Portzamparc" } }
{ "Artist" : { "DisplayName" : "Bernard Tschumi" } }
{ "Artist" : { "DisplayName" : "Emil Hoppe" } }
{ "Artist" : { "DisplayName" : "Bernard Tschumi" } }
{ "Artist" : { "DisplayName" : "Bernard Tschumi" } }
{ "Artist" : { "DisplayName" : "Bernard Tschumi" } }
{ "Artist" : { "DisplayName" : "Bernard Tschumi" } }
{ "Artist" : { "DisplayName" : "Emil Hoppe" } }

但是,当我尝试对此查询进行匹配时,

db.Artworks.aggregate( [{ $lookup : { from : "Artists", localField : "Artist", foreignField : "_id", as : "Artist"} }, {$unwind:"$Artist"},{$project: {"_id":0,"Artist.DisplayName":1}}, {$match: {"Artist.DisplayName":"Otto Wagner"}}])我收到以下错误:

Error: command failed: { "ok" : 0, "errmsg" : "InMatchExpression equality cannot be undefined", "code" : 2, "codeName" : "BadValue" } : aggregate failed at src/mongo/shell/assert.js:13

这是为什么?如何在没有出现此错误的情况下进行$ match?

0 个答案:

没有答案