title: MongoDB filter documents after aggregating to count based on type of fields
body: <p>I have been able to create an aggregation query to count by a field of my data object.</p>
  
  <pre><code>db.getCollection.aggregate([
  {"$group" : {"_id": "$attr", "count": {"$sum" : 1}}},
  {"$sort": {"count": -1}}
  ])
  </code></pre>
  
  <p>which results in a <code>{_id,count}</code> based documents sorted in descending order of count. All good until now. </p>
  
  <p>What I am trying next is to <code>filter</code> in (match) only those documents which have count above <strong><code>N</code></strong> (say 100) threshold. But when I execute:</p>
  
  <pre><code>db.getCollection.aggregate([
  {"$group" : {"_id": "$attr", "count": {"$sum" : 1}}},
  {"$sort": {"count": -1}},
  {"$match": {"count": {$gte:["count",100]}}}
  ])
  </code></pre>
  
  <p>the query returns empty results. What is the way to achieve this? I have also tried usinng <code>$filter</code> instead of <code>$match</code> to no success.</p>