Met
Met

Reputation: 25

Neo4j 2.2.0 show/delete node with no properties

I've got a node with no properties in it and want to show/find it then delete it. It shows up as blank and has a [:KNOWS] relationship to 2 other nodes.

(null node)-[:KNOWS]->(Ian),(Johan)

I can't just Match nodes with no name property because I have other nodes with no name property.

Is it possible to show this node then delete it? Also, is this possible to do in the webadmin > Data browser?

Thanks, M

Upvotes: 1

Views: 1487

Answers (1)

albertoperdomo
albertoperdomo

Reputation: 1949

Can you match against a node with no properties and that relationship? Or are there others that would be matched that you want avoid deleting?

I mean:

MATCH (n)-[r:KNOWS]->(p:Person)
WHERE p.name IN ["Ian","Johan"]
DELETE r,n;

If you have other nodes which might be matched by this query, you can try excluding those by implying that n should not have a specific property:

MATCH (n)-[r:KNOWS]->(p:Person)
WHERE p.name IN ["Ian","Johan"]
AND NOT has(n.name)
DELETE r,n;

You might want to test the results first before actually deleting:

MATCH (n)-[:KNOWS]->(p:Person)
WHERE p.name IN ["Ian","Johan"]
AND NOT has(n.name)
RETURN n;

I hope this answers your question.

Upvotes: 2

Related Questions