Reputation: 6364
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?
Upvotes: 1
Views: 147
Reputation: 4052
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)
Upvotes: 2