title: Group query upon nested object in mongodb
body: <p>I am looking at performing a group by upon a given value within a nest object. For example, my document structure is as follows:</p>
  
  <pre><code>{ 
    "ip_address": "192.168.132.12",
    "timestamp" : "2014-08-28T06:41:24",
    "response" : 200,
    "uri": {
       "term": "value A",
       "page" : "1",
       "category" : "category 1"
    }
  }
  </code></pre>
  
  <p>What I am looking at achieving is performing a group aggregate upon the <code>uri.term</code> field. I know how this is achieved for a direct field, e.g. <code>"ip_address"</code>:</p>
  
  <pre><code>db.search_stb.aggregate({ $group : {_id : "$ip_address", total : { $sum : 1 }} });
  </code></pre>
  
  <p>but I'm completely stuck on how to do this for the nested object.</p>
  
  <p>Any help would be much appreciated! </p>