I have duplicate relationships between nodes e.g:
A ->{weight: 1} B
A ->{weight: 1} B
A ->{weight: 1} B
and I want to merge these relations into one relation of the form: A->{weight: 3} B for my whole graph.
I tried something like the following:
start n = node(*)
match (n)-[r:OCCURENCE]->()
Set r.weight = count(*)
count(*)
But my graph is really big and with this query edges are updated twice for each node A and B. Furthermore the old relationships are not deleted. Don't know how to model these two aspects in one query. Hope someone can help.
EDIT:
Tried some other querys with node() and relationship() e.g
start n = node(*) match ()-[r:OCCURENCE]->() set n.SumEdgeWeight = sum(r.weight)
They are processing horrible slow. Is there any other faster way when I need to update all nodes? I found this topic [1] in the Neo4j community. Is it possible that my querys run with the java core api faster?
[1] https://groups.google.com/forum/#!topic/neo4j/4SSxvNsuQsY
Regards.