Hi guys,
I need some hints from experts to help me to do bulk update to properties on relationships.
I'm using java API to parameterize the data I want to update, one piece of my data looks like:
{"from":"241919837","to":"330970321","label":"ACT_IN","properties":{"AUTHORITY":1.0,"GENERAL_RELATION_WEIGHT":0.0,"SCORE":0.0,"IS_CORE_RELATION":0.0}}
The Cypher I'm using is:
CALL apoc.periodic.iterate(
"unwind $update1 as row match (n:Entity{eid:row.from})-[r]-> (m:Entity{eid:row.to}) where type(r) = row.label return r, row.properties as properties",
"CALL apoc.create.setRelProperties(r, keys(properties), [k in keys(properties)|properties[k]]) yield rel return 'n'",{batchSize:1, parallel:true,params:{update1:$update1}})
This query is relatively slow, some reasons I guess can be:
- plain Cypher doesn't support dynamic type match on relationship, so I have to use clause like type(r) = row.label to find the relationship
- Something strange happened in apoc.create.setRelProperties
By the way, I'm using enterprise version 3.2.x, so in this version it seems like apoc.merge.relationship doesn't work as expected, it will not update the properties. so following doesn't work for me.
CALL apoc.periodic.iterate(
"unwind $update1 as row match (from:Entity{eid:row.from}), (to:Entity{eid:row.to}) return from, to, row.label as label, row.properties as properties",
"CALL apoc.merge.relationship(from, label, {}, properties, to) yield rel return 'n'",{batchSize:1, parallel:true,params:{update1:$update1}})
Is there any way to accelerate my update? Any hint will be well appreciated.