Issue with $lookup pipeline in MongoDB Compass

I try to reproduce the pipeline from “Basic Joins” lecture in MongoDB Compass. I have 1 $match stage:

  year : {$gte:1980, $lt:1982}

which returns results and $lookup stage:

  from: 'comments',
  let: {'id': '$_id'},
  pipeline: [
      {'$expr': {'$eq':['$movie_id', '$$id']}}
  as: 'movies_comments'

However, the $lookup stage shows the error:
Expected “[” or AggregationStage but “{” found

I haven’t noticed any differences or some straightforward error that causes this message. Can anyone please help?

MongoDB Compass version: Version 1.18.0 (1.18.0)

In Addition, using Mongo Shell I was able to retrieve all required information:

{ $lookup: 
{ from: "comments", 
let:{id: "$_id"}, 
pipeline: [ {$match: {$expr: {$eq:["$movie_id","$$id"]} } } ], 
as: "movies_comments" } } 

So it seems to me that the issue is in MongoDB Compass itself.

Hi @kvatashydze,

There is a syntax error. You need to use colon instead of comma.

Please try this pipeline below:

  'from': 'comments',
  'let': { "id" : "$_id" },
  'pipeline': [
        '$expr': {
          '$eq': [ "$movie_id", "$$id" ]
      '$count': 'count'
  'as': 'comments'


While exporting to language Java, above pipeline gave below error:

@Kanika thank you! cannot understand how I’ve missed that :face_with_head_bandage:

I’m having this “Unrecognized option to $lookup: let” issue as well.

“Unrecognized option to $lookup: let” - same here

Hi Everyone,

Please try exporting after unchecking the “Use Builders” option.


1 Like

That doesn’t follow how the method we are modifying is expecting the data.

Please follow the documentation here for the implementation:

Also, I have notified the COMPASS team for the update, they will be working on this soon.