Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-20-2021 05:49 PM
Sorry; I'd have to bet this is asked often .. can't find it ..
From this Url (and many examples)
https://neo4j.com/docs/cypher-refcard/current/
and then the subsection titled, 'Patterns',
Sometimes you use --> and sometimes ->
What is the difference please ?
Solved! Go to Solution.
09-20-2021 06:37 PM
Hi @daniel.farrell2626 !! Welcome to Neo4j's community!
When you write (with -->):
MATCH (p:Person {name:'Jim'})-->(b:Person) RETURN b
You are searching for all the nodes who are related to some other by any possible type of relationship in the database (nodes that have relationships going into them, not necessarily out of them). In this example, we are getting all the Person nodes (all the people) who are related with Jim.
But if you write (with -[ ]->):
MATCH (p:Person {name:'Jim'})-[:FRIENDS_WITH]->(b) RETURN b
You are searching for all the nodes that are related to some other node, but only through the FRIENDS_WITH type of relationship, i.e. all the Person nodes who are friends with Jim. So, you use the -[:REL_TYPE]-> notation to specify which type of relationship you want to traverse, and --> notation to search on every possible type of relationship.
Hope this helps!
09-20-2021 06:37 PM
Hi @daniel.farrell2626 !! Welcome to Neo4j's community!
When you write (with -->):
MATCH (p:Person {name:'Jim'})-->(b:Person) RETURN b
You are searching for all the nodes who are related to some other by any possible type of relationship in the database (nodes that have relationships going into them, not necessarily out of them). In this example, we are getting all the Person nodes (all the people) who are related with Jim.
But if you write (with -[ ]->):
MATCH (p:Person {name:'Jim'})-[:FRIENDS_WITH]->(b) RETURN b
You are searching for all the nodes that are related to some other node, but only through the FRIENDS_WITH type of relationship, i.e. all the Person nodes who are friends with Jim. So, you use the -[:REL_TYPE]-> notation to specify which type of relationship you want to traverse, and --> notation to search on every possible type of relationship.
Hope this helps!
09-22-2021 09:11 AM
Thank you, Luise !
..............
All the sessions of the conference are now available online