Let say I have a data sample as below:
“set”: [
{
“name”:“A”,
“dgraph.type”: “node” ,
“rating” :5
},
{
“name”:“A”,
“dgraph.type”: “node” ,
“rating” :2
},
{
“name”:“B”,
“dgraph.type”: “node” ,
“rating” :5
},
{
“name”:“B”,
“dgraph.type”: “node” ,
“rating” :1
}]
I want to find the distinct values of rating present in the data set and “sort in desc order”.
The query I tried:
query=“”"
{
find(func:type(node)) @groupby(rating)
{
count(uid)
}
}“”"
Output I got :{ {5,count:2}, {1, count:1}, {2,count:1} }
Output I expect :{ {5,count:2}, {2, count:1}, {1,count:1} } [I want all distinct values of rating and sort them in the query itself. Currently, I am adding the output I am getting in an array and hen sorting it to get desired results]