{
me as var(func: uid(<userid>)) {
sc as math(1) # Give a score of 1 to the user
fr as friend {
friend {
fscore as math(sc) # This will be number of common friends
}
}
}
# Get top ten people with highest score
TopRecommendations(func: uid(fscore), orderdesc: val(fscore), first: 10) @filter(not uid(me, fr)) { # Remove the user and his friends
name
}
}
We can use this query to find the users that need to be recommended
Further, Can we find the common friends with the recommended in this query?
A <friend> B<friend> D
A <friend> C<friend> D
D will be recommended to A,how can I get the B、C information use this query?
As I understand it from your query, you are collecting second-level friends. In other words, the friends of “A” friends. That way, the more friends of friends have repeated. More “points” you give him. And it rises in the ranking. Right? It seems to me that this is the criterion.
I didn’t quite understood this question.
In fact, C and F will be recommended for A. In your last dataset sample.
{
me as var(func: uid(<userid>)) {
sc as math(1) # Give a score of 1 to the user
fr as friend {
friend {
fscore as math(sc) # This will be number of common friends
}
}
}
# Get top ten people with highest score
TopRecommendations(func: uid(fscore), orderdesc: val(fscore), first: 10) @filter(not uid(me, fr)) { # Remove the user and his friends
name
# Fetch the friends of recommendations and intersect with the friends of uid(0x1) to get list of mutual friends.
friend @filter(uid(fr)) {
uid
name
}
}
}
}