Clearing all neo4j data in Neo4j Beta 2.0.0-RC1

70 views Asked by At

I was previously able to clear all the data in my graph with the following query:

"START n0=node(0),nx=node(*) MATCH n0-[r0?]-(),nx-[rx?]-() WHERE nx <> n0 DELETE r0,rx,nx"

But the release candidate of Neo4j 2.0.0 is no longer supporting ? for optional patterns and it's asking me to use OPTIONAL MATCH instead. I'm new to Neo4j so I'm a little stumped.

Any help clearing all my data would be really appreciated. Thanks.

2

There are 2 answers

0
jjaderberg On BEST ANSWER

The idiomatic Cypher for that is

MATCH (n)  
OPTIONAL MATCH (n)-[r]-() 
DELETE n, r
1
blim8183 On

Okay... I think I have it figured out. RC1 of 2.0.0 no longer uses a reference node so I think the query to delete everything is much simplified. Here's what I'm using:

"START n=node(*) OPTIONAL MATCH (n)-[r]-() DELETE n,r"