title: Mongodb Morphia aggregation
body: <p>I'm having trouble creating aggregation in Morphia, the <a href="http://mongodb.github.io/morphia/1.1/guides/aggregation/" rel="nofollow">documentation</a> is really not clear. This is the original query: </p>
  
  <pre><code>db.collection('events').aggregate([
    {
      $match: {
        "identifier": {
          $in: [
            userId1, userId2
          ]
        },
        $or: [
          {
            "info.name": "messageType",
            "info.value": "Push",
            "timestamp": {
              $gte: newDate("2015-04-27T19:53:13.912Z"),
              $lte: newDate("2015-08-27T19:53:13.912Z")
            }
          }
        ]
      }{
        $unwind: "$info"
      },
      {
        $match: {
          $or: [
            {
              "info.name": "messageType",
              "info.value": "Push"
            }
          ]
        }
      ]);
  </code></pre>
  
  <p>The only example in their docs was using out and there's some example <a href="https://github.com/mongodb/morphia/blob/master/morphia/src/test/java/org/mongodb/morphia/aggregation/ZipCodeDataSetTest.java" rel="nofollow">here</a> but I couldn't make it to work. </p>
  
  <p>I didn't even made it past the first match, here's what I have: </p>
  
  <pre><code>    ArrayList&lt;String&gt; ids = new ArrayList&lt;&gt;();
              ids.add("199941");
              ids.add("199951");
      Query&lt;Event&gt; q = ads.getQueryFactory().createQuery(ads);
      q.and(q.criteria("identifier").in(ids));
      AggregationPipeline pipeline = ads.createAggregation(Event.class).match(q);
  Iterator&lt;Event&gt; iterator =  pipeline.aggregate(Event.class);
  </code></pre>
  
  <p>Some help or guidance and how to start with the query or how it works will be great.</p>