I am trying to use query variables to find common profiles and then finding top matching profile on top of it using sort. Unfortunately I cannot alias facet value and unable to find top scoring record.
following is my data
_:PERSON1 <person_name> “PERSON1” . #
_:PERSON2 <person_name> “PERSON2” . #
_:PERSON3 <person_name> “PERSON3” . #
_:profile1 <profile_id> “z1” . #
_:profile2 <profile_id> “z2” . #
_:profile3 <profile_id> “z3” . #
_:profile4 <profile_id> “z4” . #
_:profile5 <profile_id> “z5” . #
_:profile6 <profile_id> “z6” . #
_:profile7 <profile_id> “z7” . #
_:profile8 <profile_id> “z8” . #
_:profile1 <post_value> _:profile8 (score=60,field=“post_value”,match=“B”,value=“AAB”) . #
_:profile1 <post_value> _:profile7 (score=70,field=“post_value”,match=“A”,value=“AAB”) . #
_:profile2 <post_value> _:profile7 (score=65,field=“post_value”,match=“BA”,value=“AAB”) . #
_:profile2 <post_value> _:profile5 (score=85,field=“post_value”,match=“AB”,value=“AAB”) . #
_:profile4 <post_value> _:profile5 (score=80,field=“post_value”,match=“AB”,value=“AABB”) . #
_:profile6 <post_value> _:profile5 (score=90,field=“post_value”,match=“AB”,value=“BAA”) . #
_:profile8 <post_value> _:profile1 (score=60,field=“post_value”,match=“AAB”,value=“B”) . #
_:profile7 <post_value> _:profile1 (score=70,field=“post_value”,match=“AAB”,value=“A”) . #
_:profile7 <post_value> _:profile2 (score=65,field=“post_value”,match=“AAB”,value=“BA”) . #
_:profile5 <post_value> _:profile2 (score=85,field=“post_value”,match=“AAB”,value=“AB”) . #
_:profile5 <post_value> _:profile4 (score=80,field=“post_value”,match=“AABB”,value=“AB”) . #
_:profile5 <post_value> _:profile6 (score=90,field=“post_value”,match=“BAA”,value=“AB”) . #
_:profile1 <belongs_to> _:PERSON1 . #
_:profile2 <belongs_to> _:PERSON1 . #
_:profile3 <belongs_to> _:PERSON1 . #
_:profile4 <belongs_to> _:PERSON1 . #
_:profile6 <belongs_to> _:PERSON2 . #
_:profile7 <belongs_to> _:PERSON2 . #
_:profile8 <belongs_to> _:PERSON2 . #
_:profile5 <belongs_to> _:PERSON3 . #
profile belongs to person and it’s a reverse edge. Given 2 person names, I need to identify top scoring post_value edge. In this case if we select person1 and person2, top scoring edge will be
_:profile2 <post_value> _:profile5 (score=85,field=“post_value”,match=“AB”,value=“AAB”) . #
I would like to use sort feature so that I get access to full record.
Following is my query to get all common post values between Person1 and Person2
{
var(func: eq(person_name, "PERSON1")) {
~belongs_to{
profile_id
post_value{
A as profile_id # A
}
}
}
var(func: eq(person_name, "PERSON_2")) {
~belongs_to{
B as profile_id{ # B
}
}
}
level3(func: uid(A)) @filter(uid(B))@cascade @normalize{ # profiles from both A & B
source_profile_id: profile_id
belongs_to@filter(eq(person_name, "PERSON2")){
source_person_name: person_name
}
post_value @facets(field, match, score, value, orderdesc: score){
belongs_to@filter(eq(person_name, "PERSON1")){
target_person_name: person_name
}
}
}
}
But I am interested in identifying only highest scored post_value between Person1 and Person2.
Please note that profile1 might have multiple post_value edges hence I need to first find common profiles between selected persons and then find highest post value for each profile and then finally finding top scoring among all profiles.
Please help. Thank you.