Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
06-13-2021 09:30 PM
Hello,
I am going through the Getting Started docs and As I was trying the last Cypher example, which is:
CREATE (a:Person { name:"Tom Hanks",
born:1956 })-[r:ACTED_IN { roles: ["Forrest"]}]->(m:Movie { title:"Forrest Gump",released:1994 })
CREATE (d:Person { name:"Robert Zemeckis", born:1951 })-[:DIRECTED]->(m)
RETURN a,d,r,m
I found that the :DIRECTED
relationship is returned and displayed although it is not mentioned in the return statement.
Can anyone explain why is that?
I know that it was created because we specified that in the second CREATE
command and we didn't give it a variable.
But my question is why it has been RETURN
ed? Is that the case that whenever we RETURN
any two nodes (m and d in this example), the relationship(s) between them are being returned by default?
Thank you in advance.
06-16-2021 01:35 AM
Hi,
the relationship between nodes is not always returned. In your case you can suppress the output of the relationship when you uncheck the "Connect result nodes" checkbox in the browser settings.
06-17-2021 04:02 PM
To add more context, the "Connect result nodes" feature in the browser can be useful when exploring your data, as it queries for and gives back all the relationships that exist between the nodes returned even if you didn't ask for them. Obviously in cases where you want only specific relationships, it's going to interfere with the graphical results, so uncheck it for those queries.
All the sessions of the conference are now available online