title: Spring Data for MongoDB aggregation query
body: <p>I'm struggling with translating this mongoDB query in Spring Data MongoDB:</p>
  
  <pre><code>db.applicates.aggregate(
     [
     {
        "$match": {
          "claimantCategory": 1
        }
      },
        {
          $group : {
             _id : { month: { $month: "$claimDate" }, day: { $dayOfMonth: "$claimDate" }, year: { $year: "$claimDate" } },
         count: { $sum: 1 }
      }
    }
     ]
  )
  </code></pre>
  
  <p>I've tryed this:</p>
  
  <pre><code>TypedAggregation&lt;Applicate&gt; aggregation = newAggregation(Applicate.class,
              match(Criteria.where("claimantCategory").is(claimantCategory)),
              project("claimDate")
                      .andExpression("dayOfMonth("+"\""+"claimDate"+"\""+")").as("day")
                      .andExpression("month(claimDate)").as("month")
                      .andExpression("year(claimDate)").as("year"),
              group(fields().and("day").and("month").and("year"))
                      .count().as("count"));
  AggregationResults&lt;ClaimsAggregator&gt; groupResults = mongoOperations.aggregate(aggregation, ClaimsAggregator.class);
  </code></pre>
  
  <p>But it fails with exception : can't convert from BSON type String to Date</p>
  
  <p>My Applicate.class:</p>
  
  <pre><code>public class Applicate {
  
  @Id
  private String id;
  
  private int claimId;
  
  @DateTimeFormat (iso = DateTimeFormat.ISO.DATE)
  private Date claimDate;
  
  private int codeOfForm;
  private String claimStatus;
  private String fio;
  private int claimantCategory;
  private int serviceCode;
  private String subserviceName;
  private String departmentName;
  //getter,setters, constructor
  }
  </code></pre>
  
  <p>ClaimsAggregator.class:</p>
  
  <pre><code>public class ClaimsAggregator {
  private String claimDate;
  private int count;
  ....
  }
  </code></pre>