I can’t seem to get a count working when I’m recursing through the graph and applying a filter on the node I want to issue the count on. I have a depth of 10 set on the recurse.
I started with:
count(myNode) myNode @filter(NOT eq(name, "Bob"))
Result: I found that the query was counting every “myNode” including the ones with name John.
I changed the count to include the filter:
count(myNode @filter(NOT eq(name, "Bob"))) myNode @filter(NOT eq(name, "Bob"))
Result: The counts now appear correct, however, I’m missing large portions of the result I’m expecting.
I reversed the order - I put count below the myNode in the query. I thought maybe the count would only count the myNodes that had been filtered above it.
myNode @filter(NOT eq(name, "Bob")) count(myNode)
Result: Back to the first problem, it’s counting all the myNodes, however all the data is present.
I kept the count below the myNode and added in the filter again.
myNode @filter(NOT eq(name, "Bob")) count(myNode @filter(NOT eq(name, "Bob")))
Result: The query is returning the proper data and is correctly counting with the filter.
Looking at the count, filter, and recurse documentation, I can’t find anything that would explain this behavior.
I’m still really new to querying DGraph querying…
Why does the order/placement of the count in the query (above vs. below the node you want to count) make a difference in what is returned? Is it expected to always need the filter too, even though the myNode was filtered in the query already?
(Or if this seems like I’ve got something else really messed up, I’d appreciate that feedback too!)