1

I am trying to delete some connected node together say Photo, with other connected nodes with relationship. Case is like this:
Album-CONTAINS_PHOTO-Photos (here could be multiple images)
Photo-taken_at-Location
Photo-HAS-Comment
Comment-ADDED_BY-User

I want to delete from Photo to Comment node. (Since Album and user is parent node hence I dont need to delete them unless n until required)
On neo4j webadmin console I am firing this query:

start pht=node:__types__(className="org.sg.domain.Photo"),
cmt=node:__types__(className="org.sg.domain.Comments") 
MATCH pht-[r:HAS]-x,pht-[t:taken_at]-x, cmt-[s]-y 
WHERE pht.photoId="MhQ2W1GrJ" AND 
pht.albumName="FirstAlbum" AND
pht.userName="abc" delete r,s,t,pht,cmt;

(where 'x' and 'y' is general placeholders.)

I am getting this output:

Invalid query
Node[7] has been deleted in this tx

(where Node[7] is denoted for Photo object. Although it shows Node[7] deleted but thats not correct).
I changed my criteria to MATCH node relationship as
MATCH pht-[r]-x,MATCH pht-[r?:HAS | :taken_at]-x,
MATCH pht-[r:HAS]-x, pht-[s:taken_at]-x, but no result.

I went through this and official link, but I guess, I am little away from something.. Kindly help.

4

1 回答 1

2

您需要将密码查询的查询和修改部分分开以更新图形WITH用作分离标记:

START pht=node:__types__(className="org.sg.domain.Photo"),
cmt=node:__types__(className="org.sg.domain.Comments") 
MATCH pht-[r:HAS]-x,pht-[t:taken_at]-x, cmt-[s]-y 
WHERE pht.photoId="MhQ2W1GrJ" AND 
pht.albumName="FirstAlbum" AND
pht.userName="abc" 

WITH r,s,t,pht,cmt
delete r,s,t,pht,cmt;
于 2013-05-27T21:14:14.177 回答