neo4j return a relationship that isn't defined

 ̄綄美尐妖づ 提交于 2021-02-02 09:55:20

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!