Cypher 将多个节点关联到一个节点
Cypher relating many nodes to one node
假设我在图表中包含所有这些对象:
5ffcedc70cc70
5ffd73259ad18
5ffd7394311bf
5ffd740fd836c
5ffd74b7001fe
5ffd746b3f457
5ffd74fc7d21d
5ffd75428691b
5ffd75f0509e0
5ffd7586a2916
5ffd789434539
5ffd78e65bae8
5ffd794fcb91a
我想将它们关联到单个节点:
David
我特别想:
MATCH (a:Object),(b:Person)
WHERE a.name = '5ffdbb309d9a6' AND b.name = 'David'
CREATE (a)-[r:CREATEDBY]->(b);
有没有办法遍历对象列表,这样我就可以说 (Object)-[CREATEDBY]->(David)
我想你需要的是一个简单的 IN 子句,
https://neo4j.com/docs/cypher-manual/current/clauses/where/#where-in-operator
MATCH (a:Object),(b:Person)
WHERE a.name IN ['5ffdbb309d9a6', '5ffd73259ad18' ...] AND b.name = 'David'
CREATE (a)-[r:CREATEDBY]->(b);
还是我遗漏了什么?
假设我在图表中包含所有这些对象:
5ffcedc70cc70
5ffd73259ad18
5ffd7394311bf
5ffd740fd836c
5ffd74b7001fe
5ffd746b3f457
5ffd74fc7d21d
5ffd75428691b
5ffd75f0509e0
5ffd7586a2916
5ffd789434539
5ffd78e65bae8
5ffd794fcb91a
我想将它们关联到单个节点:
David
我特别想:
MATCH (a:Object),(b:Person)
WHERE a.name = '5ffdbb309d9a6' AND b.name = 'David'
CREATE (a)-[r:CREATEDBY]->(b);
有没有办法遍历对象列表,这样我就可以说 (Object)-[CREATEDBY]->(David)
我想你需要的是一个简单的 IN 子句, https://neo4j.com/docs/cypher-manual/current/clauses/where/#where-in-operator
MATCH (a:Object),(b:Person)
WHERE a.name IN ['5ffdbb309d9a6', '5ffd73259ad18' ...] AND b.name = 'David'
CREATE (a)-[r:CREATEDBY]->(b);
还是我遗漏了什么?