I know this is an old post, and you could find the answer, but, just for the sake of others, I post it here.
Aggregation aggregation = Aggregation.newAggregation( .match(Criteria.where("name").is("name")) .project("name") .and(ArrayOperators.Size.lengthOfArray(ConditionalOperators.ifNull("audience").then(Collections.emptyList()))).as("sent") );
source share