Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-08-2020 12:40 PM
So when i remove the grey node, the green, pink and darkgreen nodes will be deleted as well.
I tried:
session.delete(thisnode.class, id, 5)
And a cypher solution is fine too, this didnt work either:
MATCH (n:thisnode)--(e) DETACH DELETE n,e;
What worked for me so far is:
MATCH path = (:thisnode)--()--()--() DETACH DELETE path
12-09-2020 09:25 AM
Try this:
MATCH (n:thisnode)-[r:HAS_SITUATION]-(b)
DELETE r
DETACH DELETE n
12-09-2020 10:12 AM
This only deletes the 'thisnode' node and the 'has_situation' relation.
I would like to delete all of the nodes related to the grey 'thisnode', that includes the pink and darkgreen nodes and relations as well.
This query works for me:
MATCH path = (:thisnode)--()--()--() DETACH DELETE path
Where the first '--()' selects all lightgreen nodes with any relation to the grey one, the second '--()' all pink nodes with any relation to any of the nodes that have any relation to the grey node.
This solution is not dynamic at all since i need to specify the depth of what nodes need to be deleted by adding a bunch of '--()'.
Idealy i would be able to remove all of the nodes in the picture above with a simple dynamic query regardless of the relation depth. (but not all of the nodes in the database, its not a fully connected graph)
12-09-2020 10:55 AM
Try this:
MATCH (n:thisnode)
CALL apoc.path.spanningTree(n,{maxLevel:3}) YIELD path
RETURN path
Use RETURN path to check the results, then you can use DETACH DELETE path
Change the maxLevel number according to your needs.
All the sessions of the conference are now available online