我使用以下聚合来计算具有“alertsources.date_creation”的文档“alert”上的“alertsources”,但我不知道为什么它会计算所有alertource而不是那些具有条件的那些:
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();