cancel
Showing results for 
Search instead for 
Did you mean: 

How to delete all relationships with specific type that do not have certain property name?

nebuchadnezzar
Node Link

I have graph with relationships that have type and some of that relations have property
I want to delete only relationships without property but relation with same type and with property must be untouched

1 ACCEPTED SOLUTION

glilienfield
Ninja
Ninja

The following will find all relationships of type ':REL' and delete those that have zero properties. You can add restrictions to the type of nodes it relates as well, if that is needed by adding node labels to the match pattern.

match()-[r:REL]->()
where size(keys(properties(r)))=0
delete r

You should test it first because it can't be undone. maybe execute it with 'return' instead of 'delete' so you can review the relationships it will delete.  

View solution in original post

2 REPLIES 2

glilienfield
Ninja
Ninja

The following will find all relationships of type ':REL' and delete those that have zero properties. You can add restrictions to the type of nodes it relates as well, if that is needed by adding node labels to the match pattern.

match()-[r:REL]->()
where size(keys(properties(r)))=0
delete r

You should test it first because it can't be undone. maybe execute it with 'return' instead of 'delete' so you can review the relationships it will delete.  

Thank you, everything works as it should 😊