Neo4j / Cypher Delete with Where "Unknown Identifier"

I made a mistake incompatible with attribute types. For human nodes, some have a string for the external_id property, and some have an int. I would like to remove all nodes where the property is a string. The following query is executed and seems to give the correct answer.

MATCH (n:person) WHERE TOSTRING(n.external_id) = n.external_id RETURN count(n) 

However, when I try to delete these nodes using the following query, I get "Unknown identifier` n`. ":

 MATCH (n:person) WHERE TOSTRING(n.external_id) = n.external_id DELETE n 

I'm new to Neo4j and Cypher, but it looks like this should be pretty simple. I have already deleted all relationships for these nodes. What am I missing here?

+5
source share
2 answers

Turns out this is a mistake that @JeremyKendall suggested. It appeared only because I have a uniqueness constraint on person.external_id . I found a simple solution by copying the value of the external_id property to a temporary property on each person node (without uniqueness), and then deleting all the nodes where this temporary property was a string.

0
source

Source: https://habr.com/ru/post/1240389/


All Articles