neo4j 返回未定义的关系 [英] neo4j return a relationship that isn't defined

查看:27
本文介绍了neo4j 返回未定义的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对图形数据库很陌生,所以我的问题可能完全是在我的脑海中形成的.

我有三个节点,产品、供应商和国家,如下所示(欢迎在 appraoch 上提供反馈).

我想返回产品和国家,但我想返回它们之间的关系以表明它们是连接的(我设想两个节点由一条线连接).我已经走到这一步,我可以退回产品和供应商,但无论我以哪种方式旋转语法,我似乎都无法通过退货关系将产品和国家/地区联系起来.这可能吗?

match (p1:part)<--(s1:supplier)-->(c1:country) return (p1)--(s1)

任何帮助将不胜感激.

问候,亚当

解决方案

您可以使用 APOC

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

解决方案

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:

这篇关于neo4j 返回未定义的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆