Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
02-05-2021 03:05 AM
This CYPHER
MATCH(a) WHERE ID(a) =1 MATCH(b) WHERE ID(b) = 2 CREATE (n)-[r]->(l)
of course results in duplicate relationships when run twice
which CYPHER should run to merge the duplicate relationships into one, without affecting the nodes?
Solved! Go to Solution.
02-05-2021 08:38 AM
I think this will help, but alas, the page doesn't have any examples, so you'll have to experiment:
This doc also doesn't explain the configure argument, but the config arguments are described with MergeNodes:
https://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/graph-refactoring/merge-nodes/
02-05-2021 07:37 AM
I'm not sure this works as your cypher is
MATCH(a) WHERE ID(a) =1 MATCH(b) WHERE ID(b) = 2 CREATE (n)-[r]->(l)
and your create references a node aliased as n
and one aliased as l
but I do not see where n
or l
defined.
Are you simply trying to create 1 relationship between node a
and node b
and if the above is run multiple times it should always result in only 1 relationship between a
and b
? Also, your relationship has no type. Is that what you want?
Maybe something similar to
MATCH(a) WHERE ID(a) =1 MATCH(b) WHERE ID(b) = 2 CREATE (a)-[:MY_RELATIONSHIP_TYPE]->(b)
02-05-2021 08:38 AM
I think this will help, but alas, the page doesn't have any examples, so you'll have to experiment:
This doc also doesn't explain the configure argument, but the config arguments are described with MergeNodes:
https://neo4j-contrib.github.io/neo4j-apoc-procedures/3.5/graph-refactoring/merge-nodes/
All the sessions of the conference are now available online