问题
I am quite new to graph databases so what I am asking may be completely made up in my head.
I have three nodes, product, supplier and country which looks like the below (feedback welcome on appraoch).
I would like to return the product and the country BUT I would like to return a relationship between them to show they are connected (I am envisioning two nodes connected by a line). I got this far where I can return product and supplier but no matter which way I spin the syntax I can't seem to get product and country connected by a relationship on return. Is that even possible?
match (p1:part)<--(s1:supplier)-->(c1:country) return (p1)--(s1)
Any help would be greatly appreciated.
Regards, Adam
回答1:
You can use the APOC virtual nodes and relationships functions to visualize relationships (or nodes) that do not really exist in the DB.
For example:
MATCH (p:part)<-[:SUPPLIES]-(:supplier)-[:LOCATED_IN]->(c:country)
RETURN p, c, apoc.create.vRelationship(p, 'IS_IN', {}, c) as rel
produces this visualization in the neo4j Browser:
来源:https://stackoverflow.com/questions/60845782/neo4j-return-a-relationship-that-isnt-defined