Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-28-2020 08:31 AM
Hi,
I can't figure out how to exclude some nodes from the return paths of my query, the goal here is reduce the number of possible paths and thus execution time.
The original query:
MATCH r=(u:User {displayName:"User1"})-[*5..6]->(a:Application {displayName:"App1"}) RETURN r
One the path returned is:
(User1)-[ HasRole]->(Role1)-[HasPermissionsOn]->(Role1)-[HasPermissionsOn]->(Role2)-[HasPermissionsOn]->(User2)-[HasRole]->(Role3)-[HasPermissionsOn]->(App1)
Is there a way to change the query to remove the possibility of having another User in the path ?
Thanks
10-28-2020 04:19 PM
You can try the Cypher List expressions here.
Try the query like this
MATCH r=(u:User {displayName:"User1"})-[*5..6]->(a:Application {displayName:"App1"})
WITH r, [x in nodes(r) WHERE x:User AND id(x) <> id(u) | x] as otherUsers
WITH r
WHERE size(otherUsers) = 0
RETURN r
All the sessions of the conference are now available online