Tracking zero counts

As you can see we don’t support/track negative counts (nonsensical) or zero counts (not tracked).

{
   q(func: eq(count(friend), 0)) {
       count(uid)
       name
    }
}

Result

Error Name: t

Message: : count(predicate) cannot be used to search for negative counts (nonsensical) or zero counts (not tracked).

URL: http://localhost:8080/query?timeout=60s&debug=true

Raw Error:

${
  "name": "t",
  "url": "http://localhost:8080/query?timeout=60s&debug=true",
  "errors": [
    {
      "message": ": count(predicate) cannot be used to search for negative counts (nonsensical) or zero counts (not tracked).",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ]
}

Other way

You can have a Type and then filter it by count. It works.

{
   q(func: type(Person)) @filter(eq(count(friend), 0)) {
       count(uid)
       name
    }
}
{
   q(func: has(name)) @filter(eq(count(friend), 0)) {
       count(uid)
       name
    }
}

Sample dataset

{
  "set":[
    {
      "name":"Alica","age":"13",
     "friend":[{"name":"bob","age":"12","dgraph.type":"Person"}],
      "dgraph.type":"Person"
    },
    {
      "name":"Lucas","age":"16",
      "dgraph.type":"Person"
    }
  ]
}