title: Count tweets and retweets per day using aggregation frameworks
body: <p>I am trying to count the number of retweets and tweets per day using aggregation frameworks in mongo, but I am having a problem. I can do it separetely, but when I tried to do it only using a query I am not getting any result. </p>
  
  <p>I used the next aggregation framework to get the number of retweets per day</p>
  
  <pre><code>    db.tweets.aggregate(
     [
      { $match: { "retweeted_status.id": {"$exists":true} }}
       {
         $group:
           {
             _id: { 
                  day2: { $dayOfMonth: "$created_ts"}, 
                  month2 : {$month : "$created_ts" },
                  year2: { $year: "$created_ts" },
                  },
             totalReTweetsPerDay: { $sum: 1 },
           }
       },
          { $match: { "retweeted_status.id": {"$exists":true} }}
     ]
  )
  </code></pre>
  
  <p>And I using the next code to get the number of tweets per day </p>
  
  <pre><code>   db.tweets.aggregate(
         [
           {
             $group:
               {
                 _id: { 
                      day: { $dayOfMonth: "$created_ts"}, 
                      month : {$month : "$created_ts" },
                      year: { $year: "$created_ts" },
                      },
                 totalReTweetsPerDay: { $sum: 1 },
  
  
    }
       },
       {$sort : { _id : -1}},
       {$out : "daily_tweets" }
     ]
  )
  </code></pre>
  
  <p>I would like to join these two operations in one. I tried to join it only copyng one inside the other but it is not working.</p>
  
  <p>Thanks a lot, </p>