dgraph-docs icon indicating copy to clipboard operation
dgraph-docs copied to clipboard

[Documentation]: Provide an example of how to use count a predicate that with a filter

Open rahst12 opened this issue 2 years ago • 0 comments

What version of Dgraph is the target?

v21.03.1

Documentation.

The @count documentation could be improved to show examples where the predicate is filtered inside the count, example: count(friend @filter(NOT eq(name, "Sarah")))

{
  michael(func: eq(name, "Michael")) @recurse(depth:10){
    name
    age
    owns_pet
    friend~
    friend @filter(NOT eq(name, "Sarah"))
    count(friend @filter(NOT eq(name, "Sarah")))
  }
}

Discuss post which ultimately led to an understanding that @filter and @count can be combined together: https://discuss.dgraph.io/t/how-to-filter-by-count/16915/6

Discussion post where the above information was learned with Q&A: https://discuss.dgraph.io/t/does-order-in-a-dql-query-matter/18274

GitHub Ticket https://github.com/dgraph-io/dgraph-docs/issues/461 also has references with additional confusing behavior of @filter with @recurse

Additional information.

No response

rahst12 avatar Feb 14 '23 18:02 rahst12