3
  1. I was trying to use $and to express both fields are empty
  2. Here is the code
    db.tweets_v2.aggregate({
      {match:{$and:[{replyto_id:$exist:false},{replyto_id:$exist:false}]}
    });
turivishal
  • 34,368
  • 7
  • 36
  • 59
Jay Park
  • 308
  • 1
  • 6
  • 14

2 Answers2

2

There are few fixes,

  • $exist should be $exists
  • missed {} brackets before and after in $exists
  • match should be $match
  • aggregation stages start from [] not {}
db.tweets_v2.aggregate([
  {
    $match: {
      $and: [
        { replyto_id: { $exists: false } },
        { replyfrom_id: { $exists: false } } // change your second field name
      ]
    }
  }
])

Playground

turivishal
  • 34,368
  • 7
  • 36
  • 59
1

Actually the $and is not needed, this one will also work:

db.tweets_v2.aggregate([
  {
    $match: {
        replyto_id: { $exists: false } ,
        replyfrom_id: { $exists: false }
    }
  }
])
Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110