Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
10-22-2019 11:12 AM
Is it possible to add or append values to a given key in the "onMatchProps" portion of apoc.merge.node?
Using regular Cypher, I would use ON CREATE and ON MATCH commands to add values from different rows together
ON CREATE r.data_length = row.data_length
ON MATCH r.data_length = r.data_length + row.data_length
My issue is using apoc.merge.node, I haven't been able to determine how to reference the key created onCreateProps in the onMatchProps statement.
CALL apoc.merge.node(['Label'], identProps:{key:value, …}, onCreateProps:{key:value,…}, onMatchProps:{key:value,…}})
CALL apoc.merge.node(['ip'], {key:row.ip}, {data_length:row.data_length}, {data_length:data_length + row.data_length}}) returns an error of variable "data_length" not defined.
10-23-2019 06:13 AM
apoc.merge.node
is not directly capable of doing this. How about that workaround:
SET node.data_length=node.data_length + row.data_length```
On a create you're initializing `data_length=0`. Afterwards the set unconditionally adds `row.data_length` to it.
10-24-2019 09:32 AM
Thank you. I was hoping it would be possible to do this in one step.
All the sessions of the conference are now available online