Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-25-2022 08:39 PM
I want to achieve a function which can set properties and create a realationship with the existed node when it is triggered by $createNodes params. but ,it seems don't work.
my code is as below:
Blockquote
call apoc.trigger.add('newMatch','unwind apoc.trigger.nodesByLabel($createdNodes,"物品") as node
match (m:可燃物:子类)
where m.name=node.name
set node.burnPoint=m.burnPoint,node.type=m.type
create(node)-[r:isA]->(m)
with node,m
match(n:街道:场景{name:"街道"})
create(n)-[r1:include]->(node)',{phrase:"after"})
The problem is when I use this to create a new node ,there is no property modified and relationship built.
This is my first time to request help in neo4j community, I am looking forward to be replied.
Solved! Go to Solution.
04-27-2022 09:04 AM
The problem is that apoc.trigger.nodesByLabel
cannot be used together with $createdNodes
.
it's supposed to be used with $assignedNode
, assignedRelationshipProperties
, $removedNode
and $removedRelationshipProperties
.
In fact, e.g. $assignedNode
parameter is a Map<String, List<Node>>
, where String
is the label, and the function apoc.trigger.nodesByLabel
just get the List<Node>
to which the label has been assigned, and then you can unwind
it.
Instead the $createdNodes
parameter is already a List<Node>
, therefore you can do directly the unwind
.
This should work:
call apoc.trigger.add('newMatch','unwind $createdNodes as node
with node
where "物品" in labels(node)
match (m:可燃物:子类)
where m.name=node.name
set node.burnPoint=m.burnPoint,node.type=m.type
create(node)-[r:isA]->(m)
with node,m
match(n:街道:场景{name:"街道"})
create(n)-[r1:include]->(node)',{phrase:"after"})
04-27-2022 09:04 AM
The problem is that apoc.trigger.nodesByLabel
cannot be used together with $createdNodes
.
it's supposed to be used with $assignedNode
, assignedRelationshipProperties
, $removedNode
and $removedRelationshipProperties
.
In fact, e.g. $assignedNode
parameter is a Map<String, List<Node>>
, where String
is the label, and the function apoc.trigger.nodesByLabel
just get the List<Node>
to which the label has been assigned, and then you can unwind
it.
Instead the $createdNodes
parameter is already a List<Node>
, therefore you can do directly the unwind
.
This should work:
call apoc.trigger.add('newMatch','unwind $createdNodes as node
with node
where "物品" in labels(node)
match (m:可燃物:子类)
where m.name=node.name
set node.burnPoint=m.burnPoint,node.type=m.type
create(node)-[r:isA]->(m)
with node,m
match(n:街道:场景{name:"街道"})
create(n)-[r1:include]->(node)',{phrase:"after"})
05-01-2022 12:53 AM
Thank you! It works and I understood the reason.
All the sessions of the conference are now available online