Ticket: User Report numComments returning 0 for all

hey guys i 'm having an issue with getting the numComments , they are all being return as 0. When i use:
commentCollection.aggregate(pipeline1,Critic.class).iterator().forEachRemaining(e -> mostActive.add(new Critic(e.getId(),e.getNumComments())));

This is my pipeline

Listpipeline = Arrays.asList(group("$email",
sum(“numComments”,1L)),
sort(descending(“count”)),
limit(20));

Please help me out here people, im kinda lost at the moment

You name your $sum ‘numComments’ yet you sort on ‘count’. The field ‘count’ does not exists.

im soo stupid, thank you very much for pointing that out to me. today is gonna be a long day …

ive changed it now so my pipe line is

The error im getting now is

Change for
List<? extends Bson> pipeline = Arrays.asList(group("$email", sum(“count”, 1L)), sort(descending(“count”)), limit(20)); commentCollection.aggregate(pipeline,Critic.class).into(mostActive); return mostActive;

Thank you I will try that now

Just wanted to add a read concern.

Posting potential solution is against forum policy.

sure np, will take care in future.

Where do I specify read concern value, it was never shown on the videos how to do this with the java driver.

1 Like