Hi, I have been running into this issue where I can’t seem to correctly query for the sum of the facets for multiple nodes.
For a minimal example: https://docs.dgraph.io/query-language/#facets-and-aggregation Here, instead of querying the average rating for each movie, if we wanted to simply output the sum of the ratings of each movie… I tried to run the following query:
{
var(func: has(rated)) {
rated @facets(r as rating)
total_rating as sum(r)
}
data(func: uid(total_rating)) {
name
val(total_rating)
}
}
and I get weird results like:
{
"data": {
"data": [
{
"name": "Movie 1",
"val(total_rating)": 33
},
{
"name": "Movie 2",
"val(total_rating)": 33
},
{
"name": "Movie 3",
"val(total_rating)": 33
}
]
}
}
when the sums should be 8, 7 and 10 respectively…
Any pointers on what I am doing wrong? I am guessing this has something to do with value propagation but I don’t understand what I can do to fix it.