這是Cypher支架的我的Neo4j代碼的一部分:Neo4j的暗號查詢刪除節點和所有子節點和關係
CREATE
(search{id : '0', title : 'Begin Search'}),
(telephone { id : '2' , title : 'Telephone' }),
(tablet { id : '1' , title : 'Tablet' }),
(printer { id : '3' , title : 'Printer' }),
(scanner { id : '4' , title : 'Scanner' }),
(laptop { id : '5' , title : 'Laptop' }),
(pc { id : '6' , title : 'Personal Computer' }),
(monitor { id : '7' , title : 'Monitor' }),
(galaxykids7wifi { id : '100' , model : ' Galaxy Tab 3 Kids 7.0 wi-fi', brand : 'Samsung', processor : 'Dual-Core Processor', network : 'Android Jelly Bean 4.1', memory : '8 Gb' , screen : '7 inches ', wieght : '302 g', dimensions : '111.1*188*9.9 mm' , battery : '4000 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1 Gb', kamera : '3 Mpix' }),
(galaxytab310wifi3g { id : '101' , model : ' Galaxy Tab 3 10.1 wi-fi + 3 G', brand : 'Samsung', processor : 'Dual-Core Intel Atom Processor', network : 'Android 2.2', memory : '16 Gb', memory1 : '32 Gb' , screen : '10.1 inches ', wieght : '512 g', dimensions : '176.1*243,1*7.45 mm' , battery : '6800 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1 Gb', kamera : '3 Mpix' }),
(galaxytab310wifi { id : '102' , model : ' Galaxy Tab 3 10.1 wi-fi', brand : 'Samsung', processor : 'Dual-Core Intel Atom Processor', network : 'Android 2.2', memory : '16 Gb',memory1 : '32 Gb' , screen : '10.1 inches ', wieght : '510 g', dimensions : '176.1*243,1*7.45 mm' , battery : '6800 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1 Gb', kamera : '3 Mpix' }),
(galaxytab38wifi3g { id : '103' , model : ' Galaxy Tab 3 8.0 wi-fi + 3 G', brand : 'Samsung', processor : 'Dual-Core Processor', network : 'Android JB 4.2.2', memory : '16 Gb', memory1 : '32 Gb' , screen : '8 inches ', wieght : '316 g', dimensions : '123.8*209.8*7.4 mm' , battery : '4450 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1.5 Gb', kamera : '5 Mpix'}),
(galaxytab38wifi { id : '104' , model : ' Galaxy Tab 3 8.0 wi-fi', brand : 'Samsung', processor : 'Dual-Core Processor', network : 'Android JB 4.2.2', memory : '16 Gb', memory1 : '32 Gb' , screen : '8 inches ', wieght : '314 g', dimensions : '204.8*123.8*7.4 mm' , battery : '4450 mAh', wifi : '802.11', wifi_speed : '2.4 + 5 GHz', wifi_type : 'a/b/g/n', ram : '1.5 Gb', kamera : '5 Mpix'}),
(search)<-[:TYPE]-(tablet),
(search)<-[:TYPE]-(telephone),
(search)<-[:TYPE]-(printer),
(search)<-[:TYPE]-(scanner),
(search)<-[:TYPE]-(laptop),
(search)<-[:TYPE]-(pc),
(search)<-[:TYPE]-(monitor),
(tablet)<-[:TYPE]-(galaxykids7wifi),
(tablet)<-[:TYPE] -(galaxytab310wifi3g),
(tablet)<-[:TYPE]-(galaxytab310wifi),
(tablet)<-[:TYPE]-(galaxytab38wifi3g),
(tablet)<-[:TYPE]-(galaxytab38wifi)
我試圖刪除可以說,節點1與所有的子節點連接到它(在這種情況下是產品)以及它們之間的關係。我嘗試過多種解決方案的人說,在各種網頁的工作,但我一直在得到這個
'STATEMENT_EXECUTION_ERROR' : 'Node with id 1'
我猜問題是,查詢無法讀取其中具有id : 1
節點,但使沒有意義。如果可能,請幫助我。
查詢這樣一個不工作:
start n=node(1)
match n-[*]-x
WITH x
MATCH x-[r]-() delete x,r
編輯
下面的兩個答案都不能工作。我跑的Neo4j 2.0.0 - M06
1)
MATCH (n {id:'1'})<-[r]-x-[ss*0..]-y
WHERE NOT r IN ss
OPTIONAL MATCH n-[t]->()
FOREACH (s IN ss | DELETE s)
DELETE r,y,t,n
Error: Invalid input 'P' : expected 'r/R'
"OPTIONAL MATCH n-[t]->()"
^
2)
match (n {id : '1'})
optional match n-[r]-x
delete r,x
Invalid input 'o': expected whitespace, comment, a relationship patter, .....
"optional match n-[r]-x"
^
我已經重新格式化了您的問題以使其可讀。下一次請參閱此處以瞭解如何執行此操作:http://stackoverflow.com/editing-help – jjaderberg
您正在使用Neo4j的開發(未完成)版本。請使用發佈的Neo4j 2.0 GA,如果您仍有問題,可以回覆。 – jjaderberg