cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Can I delete labels too after deleting everything?

lingvisa
Graph Fellow

For example, I delete:

MATCH (n) where n.channel = 'sports' DETACH DELETE n

Although it deletes all nodes and relationships of the 'n', the labels still shows up in the browser. It's annoying. How can I wipe out all traces of those nodes and relationships once they are deleted?

1 ACCEPTED SOLUTION

Hello @lingvisa

Your current Cypher request deletes all nodes and their relationships which have a property channel equal to sports. If you want to delete nodes more safely, you can try:

CALL apoc.periodic.iterate("MATCH (n) WHERE n.channel = 'sports' RETURN n", "DETACH DELETE n", {batchSize:1000, iterateList:true})

Now, if you still can see Labels, make sure you don't have nodes remanining and if it's not the case, you must check if there are constraints or indexes:

CALL db.indexes

You can drop an index like this (doc😞

DROP INDEX index_name

You can drop a constraint like this (doc😞

DROP CONSTRAINT constraint_name

Regards,
Cobra

View solution in original post

2 REPLIES 2

npatel
Node Clone

I think they do get deleted unless you have some index on them

Hello @lingvisa

Your current Cypher request deletes all nodes and their relationships which have a property channel equal to sports. If you want to delete nodes more safely, you can try:

CALL apoc.periodic.iterate("MATCH (n) WHERE n.channel = 'sports' RETURN n", "DETACH DELETE n", {batchSize:1000, iterateList:true})

Now, if you still can see Labels, make sure you don't have nodes remanining and if it's not the case, you must check if there are constraints or indexes:

CALL db.indexes

You can drop an index like this (doc😞

DROP INDEX index_name

You can drop a constraint like this (doc😞

DROP CONSTRAINT constraint_name

Regards,
Cobra