title: MongoDB and Spring Data. Get size of array in entity
body: <p>I have such entity.</p>
  
  <pre><code>@Document
  public class Entity{
      @Id
      private String id;
      private Set&lt;Integer&gt; ids;
  }
  </code></pre>
  
  <p>I need to get size of array <strong><em>ids</em></strong></p>
  
  <p>How it can be done using Spring Data aggregation framework?</p>
  
  <p>I'm trying something like this:</p>
  
  <pre><code>AggregationOperation match = Aggregation.match(where("id").is(id));
  AggregationOperation group = Aggregation.group("ids");
  Aggregation aggregation = Aggregation.newAggregation(match, group);
  template.aggregate(aggregation, Entity.class, Entity.class);
  </code></pre>
  
  <p>Seems like I'm doing it totally wrong.</p>