Message from discussion
Delete operation in SDN using cypher
Received: by 10.66.76.5 with SMTP id g5mr1115894paw.44.1348755498881;
Thu, 27 Sep 2012 07:18:18 -0700 (PDT)
X-BeenThere: neo4j@googlegroups.com
Received: by 10.68.222.169 with SMTP id qn9ls9914977pbc.4.gmail; Thu, 27 Sep
2012 07:18:17 -0700 (PDT)
Received: by 10.68.212.168 with SMTP id nl8mr1225562pbc.5.1348755497646;
Thu, 27 Sep 2012 07:18:17 -0700 (PDT)
Received: by 10.68.212.168 with SMTP id nl8mr1225561pbc.5.1348755497635;
Thu, 27 Sep 2012 07:18:17 -0700 (PDT)
Return-Path: <michael.hun...@neopersistence.com>
Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50])
by gmr-mx.google.com with ESMTPS id g4si1552464paw.1.2012.09.27.07.18.17
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 27 Sep 2012 07:18:17 -0700 (PDT)
Received-SPF: pass (google.com: domain of michael.hun...@neopersistence.com designates 209.85.160.50 as permitted sender) client-ip=209.85.160.50;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of michael.hun...@neopersistence.com designates 209.85.160.50 as permitted sender) smtp.mail=michael.hun...@neopersistence.com
Received: by mail-pb0-f50.google.com with SMTP id md4so1015786pbc.9
for <neo4j@googlegroups.com>; Thu, 27 Sep 2012 07:18:17 -0700 (PDT)
d=google.com; s=20120113;
h=from:mime-version:content-type:subject:date:in-reply-to:to
:references:message-id:x-mailer:x-gm-message-state;
bh=1WFsGxLmJjyiy1WC92sP+x2an1w/p8PqL+1dT8APxZ4=;
b=Ss+UMwqOApPD7EBnA4TR7ZroMdZd3jSF1WfY/ZOmTmDNBgclgCcTqkgF051X3j2vkA
a18DVOzpILHuXy2CszjZIkoM1zdrngNiDpGMpAmpvDK9HcdimYMFhgOB0uql3zWsro0c
A1aQ81xZrAydlNB5nk3e7k4WpLeUrRQ1Q0DkUyfXx3xoaciPIWSh2qASNBHRUB/7JVom
jGCEWzAfnhgHsld9lZQSYlVtNs6MC+GazEFItNblouh3C4u2X43ABYKXxzPveltPNR4F
iTjxAOCPJad5JVsKRJNt2SyFqQni5xu/BuvNWW9XsKzICwwKISyZp1M+9RUaZJoFpP7Q
40Pw==
Received: by 10.68.138.163 with SMTP id qr3mr11714854pbb.161.1348755497532;
Thu, 27 Sep 2012 07:18:17 -0700 (PDT)
Return-Path: <michael.hun...@neopersistence.com>
Received: from [10.11.1.35] (206.111.142.135.ptr.us.xo.net. [206.111.142.135])
by mx.google.com with ESMTPS id nu8sm3898400pbc.45.2012.09.27.07.18.15
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 27 Sep 2012 07:18:17 -0700 (PDT)
From: Michael Hunger <michael.hun...@neotechnology.com>
Mime-Version: 1.0 (Apple Message framework v1084)
Content-Type: multipart/alternative; boundary=Apple-Mail-9--1066376401
Subject: Re: [Neo4j] Delete operation in SDN using cypher
Date: Thu, 27 Sep 2012 07:18:14 -0700
In-Reply-To: <CAP4mnvZAMtG4t8WJTZ3vEufjg1Rh0vEkg=EEsm3mbNd9MgW...@mail.gmail.com>
To: neo4j@googlegroups.com
References: <CAP4mnvamA8sAYjPR-HbPab2DgveSmZkW3QxP8Z1+JNsJcC=...@mail.gmail.com> <CADBmhC=FHeUUJ+05bZPwaQyGPy3Ogdu2qmeBT4wAAxgYieS...@mail.gmail.com> <CAP4mnvZAMtG4t8WJTZ3vEufjg1Rh0vEkg=EEsm3mbNd9MgW...@mail.gmail.com>
Message-Id: <AA09D137-F11A-49F1-9385-EFCEAB77C...@neotechnology.com>
X-Mailer: Apple Mail (2.1084)
X-Gm-Message-State: ALoCoQkPVmWjGOf0K8rZUZpIj8Ge+95UfEDJKrPtu+np7TZxOSW0bc4mYcrCbv0wN2mi4f+iETNh
--Apple-Mail-9--1066376401
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=us-ascii
Something like:
> START a=3Dnode(1)
> MATCH (a)-[rels*0..]-(z)
> FOREACH(rel IN rels: DELETE rel)
> DELETE a
WITH z
where z-->()
> DELETE z
Michael
Am 26.09.2012 um 06:43 schrieb Abdul Azeez Shaik:
> Hi Nigel,
>=20
> Thanks for the reply. I tried executing in latest 1.8RC1 webconsole, =
it gives me following error,
> TransactionFailureException: Unable to commit transaction
>=20
> Also, Do we need to use FOREACH in this case? Can't we directly use =
DELETE a,rels,z?=20
> In my case a and z are also collections, not single node.
>=20
> Thanks,
> Abdul
>=20
> On Wed, Sep 26, 2012 at 4:49 PM, Nigel Small <ni...@nigelsmall.net> =
wrote:
> Hi Abdul
>=20
> I have recently added cascading deletion to py2neo. I use the =
following Cypher query...
>=20
> START a=3Dnode(1)
> MATCH (a)-[rels*0..]-(z)
> FOREACH(rel IN rels: DELETE rel)
> DELETE a, z
>=20
> ...where the first line determines the start node by ID. I have also =
considered looking at limits on relationship type and direction as well =
as a maximum cascade limit so you may want to consider that too.
>=20
> Cheers
> Nige
>=20
>=20
> On 26 September 2012 11:33, Abdul Azeez Shaik =
<azeeztechni...@gmail.com> wrote:
> Dear all,
>=20
> Can i delete a node along with its relationships and children using =
the following CYPHER query,=20
> "START g =3D =
node:galleryid(galleryid=3D"0511a491-62ea-41f6-9a6f-b9060e3c525a") MATCH =
g-[r]-p DELETE g, r, p"
>=20
> Its not working when i tried this in webconsole of neo4j.
> I am trying to find where i can delete a node with all its children at =
one go.
> Or do i need to delete each children and its relationships, and then =
finally parent node.
>=20
> Kindly let me know your suggestions.
>=20
> Thanks,
> Abdul
>=20
> --=20
> =20
> =20
>=20
>=20
> --=20
> =20
> =20
>=20
>=20
> --=20
> =20
> =20
--Apple-Mail-9--1066376401
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=us-ascii
<html><head></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">Something like:<div><br></div><div><blockquote type=3D"cite"><div><div =
class=3D"gmail_quote"><blockquote class=3D"gmail_quote" =
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, =
204, 204); border-left-style: solid; padding-left: 1ex; position: =
static; z-index: auto; "><div><div><font face=3D"courier new, =
monospace">START a=3Dnode(1)</font></div><div><font face=3D"courier new, =
monospace">MATCH =
(a)-[rels*0..]-(z)</font></div></div></blockquote></div></div></blockquote=
><div><blockquote type=3D"cite"><div><div =
class=3D"gmail_quote"><blockquote class=3D"gmail_quote" =
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, =
204, 204); border-left-style: solid; padding-left: 1ex; position: =
static; z-index: auto; "><div><div><font face=3D"courier new, =
monospace">FOREACH(rel IN rels: DELETE =
rel)</font></div><div></div></div></blockquote></div></div></blockquote></=
div><blockquote type=3D"cite"><div><div class=3D"gmail_quote"><blockquote =
class=3D"gmail_quote" style=3D"margin-top: 0px; margin-right: 0px; =
margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; =
border-left-color: rgb(204, 204, 204); border-left-style: solid; =
padding-left: 1ex; position: static; z-index: auto; "><div><div>DELETE =
a</div></div></blockquote></div></div></blockquote></div><div> =
WITH z</div><div> where =
z-->()<br><blockquote type=3D"cite"><div><div =
class=3D"gmail_quote"><blockquote class=3D"gmail_quote" =
style=3D"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; =
margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, =
204, 204); border-left-style: solid; padding-left: 1ex; position: =
static; z-index: auto; "><div><div><font face=3D"courier new, =
monospace">DELETE =
z</font></div></div></blockquote></div></div></blockquote><br></div><div>M=
ichael</div><div><br><div><div>Am 26.09.2012 um 06:43 schrieb Abdul =
Azeez Shaik:</div><br class=3D"Apple-interchange-newline"><blockquote =
type=3D"cite">Hi Nigel,<div><br></div><div>Thanks for the reply. I tried =
executing in latest 1.8RC1 webconsole, it gives me following =
error,</div><div><span =
style=3D"color:rgb(238,238,238);font-family:monospace;font-size:medium;bac=
kground-color:rgb(0,0,0)">TransactionFailureException: Unable to=
commit transaction</span></div>
<div><span =
style=3D"color:rgb(238,238,238);font-family:monospace;font-size:medium;bac=
kground-color:rgb(0,0,0)"><br></span></div><div>Also, Do we need to use =
FOREACH in this case? Can't we directly use DELETE a,rels,z? </div>
<div>In my case a and z are also collections, not single =
node.</div><div><br></div><div>Thanks,</div><div> Abdul<br><br><div =
class=3D"gmail_quote">On Wed, Sep 26, 2012 at 4:49 PM, Nigel Small <span =
dir=3D"ltr"><<a href=3D"mailto:ni...@nigelsmall.net" =
target=3D"_blank">ni...@nigelsmall.net</a>></span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin-top: 0px; =
margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; =
border-left-width: 1px; border-left-color: rgb(204, 204, 204); =
border-left-style: solid; padding-left: 1ex; position: static; z-index: =
auto; "><font face=3D"trebuchet ms,sans-serif">Hi Abdul</font><div><font =
face=3D"trebuchet ms,sans-serif"><br></font></div><div><font =
face=3D"trebuchet ms,sans-serif">I have recently added cascading =
deletion to py2neo. I use the following Cypher query...</font></div>
<div><font face=3D"trebuchet =
ms,sans-serif"><br></font></div><div><div><font face=3D"courier new, =
monospace">START a=3Dnode(1)</font></div><div><font face=3D"courier new, =
monospace">MATCH (a)-[rels*0..]-(z)</font></div><div><font face=3D"courier=
new, monospace">FOREACH(rel IN rels: DELETE rel)</font></div>
<div><font face=3D"courier new, monospace">DELETE a, =
z</font></div><div><font face=3D"trebuchet ms, =
sans-serif"><br></font></div><div><font face=3D"trebuchet ms, =
sans-serif">...where the first line determines the start node by ID. I =
have also considered looking at limits on relationship type and =
direction as well as a maximum cascade limit so you may want to consider =
that too.</font></div>
<div><font face=3D"trebuchet ms, sans-serif"><br></font></div><div><font =
face=3D"trebuchet ms, sans-serif">Cheers</font></div><div><font =
face=3D"trebuchet ms, =
sans-serif">Nige</font></div><div><br></div><br><div =
class=3D"gmail_quote">
<div><div class=3D"h5">
On 26 September 2012 11:33, Abdul Azeez Shaik <span dir=3D"ltr"><<a =
href=3D"mailto:azeeztechni...@gmail.com" =
target=3D"_blank">azeeztechni...@gmail.com</a>></span> =
wrote:<br></div></div><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class=3D"h5">
Dear all,<div><br></div><div>Can i delete a node along with its =
relationships and children using the following CYPHER =
query, </div><div>"START g =3D =
node:galleryid(galleryid=3D"0511a491-62ea-41f6-9a6f-b9060e3c525a") MATCH =
g-[r]-p DELETE g, r, p"</div>
<div><br></div><div>Its not working when i tried this in webconsole of =
neo4j.</div><div>I am trying to find where i can delete a node with all =
its children at one go.</div><div>Or do i need to delete each children =
and its relationships, and then finally parent node.</div>
<div><br></div><div>Kindly let me know your =
suggestions.</div><div><br></div><div>Thanks,</div><div>Abdul</div></div><=
/div><span><font color=3D"#888888"><div><br =
class=3D"webkit-block-placeholder"></div>
-- <br>
<br>
<br>
</font></span></blockquote></div><br></div><div><br =
class=3D"webkit-block-placeholder"></div>
-- <br>
<br>
<br>
</blockquote></div><br></div><div><br =
class=3D"webkit-block-placeholder"></div>
-- <br>
<br>
<br>
</blockquote></div><br></div></body></html>=
--Apple-Mail-9--1066376401--