Query help: how to get everyone don't know

hi, I need to count how many people each person interacts with that he doesn’t know.
In this way, in the B red box, filtering doesn’t work, and the results still include the person that this person knows.

In this way, the filter of the B red box works, but it filters out not only the person who knows the person, but the whole person who has entered (assuming the input is ten people) knows.

How can I write to filter out the people that everyone knows correctly?

  1. The first query won’t work. Cuz the variable doesn’t propagate well in multiple level querying.
  2. The second one would be the right approach. But you should limit it for a single user. Not 3 or more. Cuz Dgraph injects all users found in “knows_uid” from all users found. Unless you wanna this behave.

I have written about the first issue here Promise a nested block (under construction - I'm still working in the use case)

For the second one, I think a loop might help there FOREACH func in DQL (loops in Bulk Upsert)

What do you mean? collect a list of users and then use them to filter? your first query is collecting users in a different way. If you wanna use a list of users as a parameter, this should be a separate block with its constraints and then you can use it in the target block. But I feel like that’s not what you mean.

1 Like