Sort a match group by id in aggregate
<p>(Mongo newbie here, sorry) I have a mongodb collection, result of a mapreduce with this schema : </p>

<pre><code>{
  "_id" : "John Snow",
  "value" : {
    "countTot" : 500,
    "countCall" : 30,
    "comment" : [
      {
        "text" : "this is a text",
        "date" : 2016-11-17 00:00:00.000Z,
        "type" : "call"
      },
      {
        "text" : "this is a text",
        "date" : 2016-11-12 00:00:00.000Z,
        "type" : "visit"
      },
      ...
    ]
  }
}
</code></pre>

<p>My goal is to have a document containing all the comments of a certain type. For example, a document John snow with all the calls. </p>

<p>I manage to have all the comments for a certain type using this :</p>

<pre><code>db.general_stats.aggregate(

    { $unwind: '$value.comment' },

    { $match: {
        'value.comment.type': 'call'
    }}
)
</code></pre>

<p>However, I can't find a way to group the data received by the ID (for example john snow) even using the $group property. Any idea ?</p>

<p>Thanks for reading. </p>