cypher


cypher delete node and all the list of related node


I'm trying to delete an entire list starting from a given node to the end of the list.
Where is the list of the root,relationship and child nodes. The child nodes can have an undetermined nodes.
(r:Root {name:'masterDoc'})<-[p:previous]<-(s1:schema)<-[p1:previous]<-(s2:schema)<-[pn:previous]<-(sn:Schema)
When I run the cypher query below I'm getting a Type mismatch: expected Node, Path or Relationship but was Collection
MATCH (n:`Root` {name:'masterDoc'})-[r:previous*]-(s) delete s,r,n
Any Idea?
You want to pull out the longest path of nodes, iterate over the relationships and delete each one and then iterate over the nodes and delete them.
NOTE: This assumes that each node in the path is no longer anchored to anything other than the nodes in the path otherwise they will not be able to be removed.
// match the path that you want to delete
match p=(:Root {name: 'masterDoc'} )-[:previous*]->()
with p
// order it in descending order by length
order by length(p) desc
// grab the longest one
limit 1
// delete all of the relationships
foreach (r in relationships(p) | delete r)
// delete all of the remaining nodes
foreach (n in nodes(p) | delete n)

Related Links

ORDER BY and the event horizon
Get all nodes that do not have a specific relation
How to use CASE to create composite score in Cypher
Cypher: Can we put if…else in where condition?
Neo4jclient C#: WHERE x IN List
Neo4j graph showing multiple relationship between same nodes on top of each other
Dynamic loading of menu options seems not to respect order of results from cypher
How to use sub queries with multiple (different) columns returned
Cypher Query - conditionally return a relationship
neo4j cypher query too slow
Whats wrong with Neo4j 2.0 Query?
Cypher Query returning value
Neo4J 2.0 How to refactor the database to introduce Date nodes
How to get distinct node on condition Cypher-Neo4j
cypher help - create or update a node
Neo4j Configuration for 4M Nodes 10M relationship

Categories

HOME
elasticsearch
mc
windows-8.1
swi-prolog
hid
message-queue
loopbackjs
code-formatting
android-emulator
malware
web2py
material-components
azure-mobile-services
capistrano
roku
cqrs
lapack
fbloginview
documentum
global-variables
phonegap-build
reselect
cocos2d-android
jaspersoft-studio
salt-cloud
raml
social-tables
nurbs
webviewclient
unrar
xdebug
sfml
sparkle
region
substance
mapnik
commonsware-cwac
jfxtras
bluemixtools
jade4j
twilio-php
assert
game-center
jacoco-maven-plugin
newtons-method
moinmoin
vesta
code-push
kitura
audio-converter
webalizer
lightning-workbench
renderman
mura
asp.net-web-api-routing
connect-direct
email-forwarding
network-protocols
dblink
case-when
mechanicalturk
business-rules
perl-data-structures
annotatorjs
livereload
wicked-pdf
vaadin4spring
django-validation
grinder
odesk
outlook.com
miniconda
ambiguity
auto-generate
mixins
hmisc
gql
libz
swagger-maven-plugin
python-curses
famo.us
dmake
iplimage
libgcc
accessory
refit
map
armv6
mft
frontbase
mute
jquery-transit
node.js-stream
.net-remoting
xs
sly-scroller
reentrancy
cmath
examine
dojo-1.9
simplecov
onconfigurationchanged
cakeyframeanimation
jzmq
wcf-callbacks
botnet
directshow.net
ognl
anonymous-types
pyjamas
jdownloader
uninstaller
activestate
principles
facebook-fbml
rawcontacts
community-server

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App