How to create edges based on the equality check on vertex attributes in Cypher?

安稳与你 提交于 2019-12-11 10:26:46

问题


How to create edges based on the equality check on vertex attributes in Cypher?

For example: lets say I have one object like this

Employees {name: "abc, country: "NZ"}

and lets say I have the following objects

Manager { name: "abc", depatment: "product"}

Manager {name: "abc", depatment: "sales"}

Manager {name: "abc", depatment: "marketing"}

Now I want to create all the edges where Employees.name = Manager.name

How do I write the Cypher query to create all 4 vertices and 3 edges?


回答1:


Find the pairs first with MATCH clause and then CREATE a relationship between them.

MATCH (e:Employees),(m:Manager)
WHERE e.name=m.name
WITH e,m
CREATE (m)-[:REL_NAME]->(e)


来源:https://stackoverflow.com/questions/55354623/how-to-create-edges-based-on-the-equality-check-on-vertex-attributes-in-cypher

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