I have a graph where nodes can either be 'resources' or 'external dependencies'.
A resource (a.k.a. microservice) may have the following relationships:
- resource - DEPENDS_ON -> externalDependency (maxDepth of 1, one direction)
- resource - CONNECTS_TO - resource (any depth, any direction)
I'm currently searching for all resources and their relationships (either in or out) with the following query:
Match (Resource)-[:CONNECTIONS*0..]-(ResourceDependency)-[:DEPENDS_ON*0..]-(ExternalDependency)
Where Resource.name =~ '.*service_name.*'
Return Resource, ResourceDependency, ExternalDependency
Since resources can depend on each other they may form a circular relationship. When this happens and one of the nodes that belongs to the circle matches the "name" criteria, the query never finishes and neo4j browser eventually freezes.
If I try to lower the CONNECTIONS depth/maxHops to eight (*0..8) it works perfectly. Unfortunately I already have relationships greater than that so this is not a viable solution (they just don't form any circular rel.).
UPDATES:
Setting the maxHops to any value higher than 8 makes Neo4j browser crash.
Since 'resource' nodes can have N depth relationships with each other (and eventually form a circular reference) the query needs to traverse all the graph getting both in and out relationships of all resource nodes AND their (one depth) external dependencies.
QUESTION:
How can I achieve this "where" clause without performance issues on circular relationships?