How can i get cumulative score (sum of person_name_direct and city_name_direct) from one user to all the other user’s ? Let me know if i need to change the way i store values in order to get the cumulative score’s
{
everyone(func: eq(user_id, “12345”)) {
person_name_direct @facets(person_score as score){
personScore as math(person_score)
}
city_name_direct @facets(city_score as score){
cityScore as math(city_score)
}
personScores as sum(val(personScore))
cityScores as sum(val(cityScore))
cumScore as math(personScores + cityScores)
cs: val(cumScore)
}
}
But this gives me sum of all the person_score’s instead of between one user to other user. How can i maintain the cumulative score between each pair of user’s
or you may need to merge in steps. Using the blocks to solve what you want and then in the end return the results.
Example: You want to add the punctuation of each user. Hence return these values separately and compare.
But Dgraph would not have a comparison tool. Except “k-shortest”. I had understood that you wanted only the sum of everything for each user. But you want the sum of the score and a comparison.
This part of your query that finds the user_id. I would recommend you to use the UID of Dgraph and look for everyone (func: uid (0x12345)) {- Because it is much faster and does not generate load and other side effects.