Reputation: 636
I am using Neo4j Version 3.5.4 and doing the Introduction Course Exercises on the movies dataset. I noticed that I accidentally introduced duplicates in some relationships as shown:
MATCH (p:Person)-[r:ACTED_IN]->(m:Movie)
WHERE m.title = 'Forrest Gump'
RETURN p,m,r
How can I combine them so I just keep one of the duplicates?
Thanks!
Upvotes: 0
Views: 42
Reputation: 12704
You can use tail and collect functions to remove the duplicates:
Here it is:
MATCH (p:Person)-[r:ACTED_IN]->(m:Movie)
WHERE m.title = 'Forrest Gump'
WITH tail(collect(r)) as coll , p
FOREACH (x in coll| DELETE x)
Upvotes: 1