I use the following aggregation to count "alertsources" on document "alert" that has a specifique "alertsources.date_creation" but I don't know why it counts all the alertsources instead of those who has the criteria :
final Aggregation aggregation = Aggregation.newAggregation(
Aggregation.match(Criteria.where("alertsources.date_creation").regex(date)),
Aggregation.match(Criteria.where("descA").is(alertName)),
//regex(".*"+date+".*")
Aggregation.unwind("alertsources"),
Aggregation.unwind("descA"),
Aggregation.group().count().as("count"));
//System.out.println("----------"+mongoTemplate.aggregate(aggregation, Alert.class, MentionCount.class).getRawResults()+"-----");
List<MentionCount> agregResult = mongoTemplate.aggregate(aggregation, Alert.class, MentionCount.class).getMappedResults();