You'd have to group by the nodes then and collect the relationships into a collection and delete all except the first.
Do something like this MATCH (n:SomeLabel)-[r:REL_TYPE]->(m:AnotherLabel) WITH n, m, collect(r)[1..] as rels FOREACH (r in rels | DELETE r) On Mon, Jul 21, 2014 at 9:22 PM, Conar Welsh <[email protected]> wrote: > Would this same query work without specific start points? > i.e. > > MATCH (:SomeLabel)-[r:REL_TYPE]->(:AnotherLabel) > SKIP 1 > DELETE r > > Basically I am trying to introduce a CREATE UNIQUE, however the data in > the graph already has duplicates, so the CREATE UNIQUE is failing due to > multiple paths, and I want to clean it up manually. > > > On Tuesday, August 13, 2013 1:35:59 AM UTC-6, Michael Hunger wrote: > >> START n1=node(7727), n2=node(7730) >> MATCH n1-[r:SKILL]->n2 >> >> SKIP 1 >> delete r >> >> >> Michael >> >> Am 13.08.2013 um 08:32 schrieb Priyadarshi Lahiri <[email protected]>: >> >> When I run this query: >> >> START n1=node(7727), n2=node(7730) >> MATCH n1-[r:SKILL]->n2 RETURN r >> >> it gives me a list of duplicate relationships that I have between the two >> nodes. what do I add to the cypher query to iterate over the relationship >> to keep one relationship and delete the rest? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Neo4j" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >> >> -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
