cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to create [:*1..] type matches without creating a direct relationship

How to query out MATCH (a:company)-[:orders]->(:item)-[made_by]->(b:company)-[:orders]->(:item)-[made_by]->(:c:company) amd so on without creating a direct relationship between two company nodes.

1 REPLY 1

MuddyBootsCode
Graph Steward

Do you have access to the ID's of each company you're trying to query? If so you could probably do something like:

MATCH (s:startCompany {id: startID})-[o]->(i)->[m]->(e:endCompany{id: endID})
return s, o, i, m e

If you wanted to check for other companies in the middle you could add an optional match for companies as well.

This answer is based on this example from Stack Overflow https://stackoverflow.com/questions/38423683/get-all-relationships-for-a-node-with-cypher

If you know the count then it could be something like r*1..3 as well