I’m trying to better understand the use case for the @count
index in Dgraph.
From what I gather, it’s only necessary when we need to filter or sort nodes based on the number of values they have for a specific predicate — for example, how many friends
a node has. In that case, we’d write something like:
{
q(func: has(friends)) @filter(ge(count(friends), 3)) {
uid
}
}
But in a query like this:
{
var(func: type(someType)) @filter(has(sth)) {
someuid as uid
}
count_num(func: uid(someuid)) @filter(type(someType)) {
count_num: count(uid)
}
}
We’re simply counting the number of nodes matching a condition, not counting predicate values. So I assume the @count
index is not required here.
Is this understanding correct?
Thanks!