0
votes

I am running a query to find the path from a user to a permission node in neo4j and I want to make sure it doesn't traverse some relationships. Therefore I've used the following cypher :

PROFILE 
MATCH path = (u:user { _id: 'ea6b17e0-3b9e-11ea-b206-e7610aa23593' })-[r:accessRole|isMemberOf*1..5]->(n:PermissionSet { name: 'project'})
WHERE all(x IN r WHERE NOT (:PermissionSet)-[x]->(:user))
RETURN path

I didn't expect the where clause to trigger so many hits. I believe I'm not writing my test correctly. (2000 nodes/ 3500 rels => 350,000 hits for "(:PermissionSet)-[x]->(:user)"

any advice?

1

1 Answers

0
votes

Not sure this is the correct answer, but I added a WITH statement

PROFILE 
MATCH path = (u:user { _id: 'ea6b17e0-3b9e-11ea-b206-e7610aa23593' })-[r:accessRole|isMemberOf*1..5]->(n:PermissionSet { name: 'project'})
WITH path,r
WHERE all(x IN r WHERE NOT (:PermissionSet)-[x]->(:user))
RETURN path

And the dbhits for "(:PermissionSet)-[x]->(:user)" went down to 2800 hits.

I can guess why it does that, but I'd love some more experts explanations, and is there a better way to do it? (this way is fine with me performance-wise)