ah I see my bad,
I didn’t see that the value of u1_u2_total_intersect_interests
doesn’t appear
I’ve fixed the query with this new query
{
var(func: uid(0x6)){
recommender.User.interests{
~recommender.User.interests{
u2_total_interests as count(recommender.User.interests)
}
}
}
var(func: uid(0x6)){
norm as math(1)
u1_total_interests as count(recommender.User.interests)
u1_interests as recommender.User.interests{
~recommender.User.interests{
# u2_total_interests as count(recommender.User.interests)
u1_norm_total_interests as math(u1_total_interests / norm)
u1_u2_total_intersect_interests as count(recommender.User.interests @filter(uid(u1_interests)))
u1_u2_total_union_interests as math(u1_norm_total_interests + u2_total_interests)
divs as math(1.0 * u1_u2_total_intersect_interests / ( u1_u2_total_union_interests * 1.0 ))
distance as math(1 - divs)
}
}
}
q(func: uid(0x6)) {
recommender.User.id
val(norm)
val(u1_total_interests)
recommender.User.interests @filter(uid(u1_interests)) {
recommender.Interest.id
~recommender.User.interests @filter(not uid(0x6)) {
recommender.User.id
recommender.Interest.id
val(norm)
val(u2_total_interests)
val(u1_norm_total_interests)
val(u1_u2_total_intersect_interests)
val(u1_u2_total_union_interests)
val(divs)
val(distance)
}
}
}
}
and now it’s working properly
{
"data": {
"q": [
{
"recommender.User.id": "c3rutfb2dnce1sh6njl0",
"val(norm)": 1,
"val(u1_total_interests)": 5,
"recommender.User.interests": [
{
"recommender.Interest.id": "doodle",
"~recommender.User.interests": [
{
"recommender.User.id": "c49049b2dncb3h8305lg",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
},
{
"recommender.User.id": "c49058j2dncb3h8305q0",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
}
]
},
{
"recommender.Interest.id": "poodle",
"~recommender.User.interests": [
{
"recommender.User.id": "c49049b2dncb3h8305lg",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
},
{
"recommender.User.id": "c4904ir2dncb3h8305n0",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
},
{
"recommender.User.id": "c49058j2dncb3h8305q0",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
}
]
},
{
"recommender.Interest.id": "vienetta",
"~recommender.User.interests": [
{
"recommender.User.id": "c4904ir2dncb3h8305n0",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
},
{
"recommender.User.id": "c4904qb2dncb3h8305og",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
}
]
},
{
"recommender.Interest.id": "bables",
"~recommender.User.interests": [
{
"recommender.User.id": "c4904ir2dncb3h8305n0",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
},
{
"recommender.User.id": "c4904qb2dncb3h8305og",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
},
{
"recommender.User.id": "c49058j2dncb3h8305q0",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
}
]
},
{
"recommender.Interest.id": "piglet",
"~recommender.User.interests": [
{
"recommender.User.id": "c49049b2dncb3h8305lg",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
},
{
"recommender.User.id": "c4904qb2dncb3h8305og",
"val(u2_total_interests)": 3,
"val(u1_norm_total_interests)": 5,
"val(u1_u2_total_intersect_interests)": 3,
"val(u1_u2_total_union_interests)": 8,
"val(divs)": 0.375,
"val(distance)": 0.625
}
]
}
]
}
]
},
"extensions": {
"server_latency": {
"parsing_ns": 1690600,
"processing_ns": 8530900,
"encoding_ns": 147100,
"assign_timestamp_ns": 2196600,
"total_ns": 13741500
},
"txn": {
"start_ts": 11427
},
"metrics": {
"num_uids": {
"": 19,
"_total": 62,
"recommender.Interest.id": 9,
"recommender.User.id": 5,
"recommender.User.interests": 14,
"~recommender.User.interests": 15
}
}
}
}
thank you so much @anand