unable to delete node labels in neo4j

梦想的初衷 提交于 2019-12-22 13:06:52

问题


I have created 2 labels Person,Movies by :

CREATE (ee:Person { name: "test", id: "1" })

CREATE (m:Movie { name: "movie_1", id: "2" })

When I Run :

START n=node(*)
OPTIONAL MATCH (n)-[r]-()
DELETE n,r;

But The Label still exists. How can I delete the label?


回答1:


So, you don't actually delete labels you remove them (e.g. remove m:Movie). delete is used to remove nodes and/or relationships from the database.

The following cypher example will match your movie node, remove the existing label, add a new one and return the node. When it is returned you can see that it has a different label.

match (m:Movie) 
remove m:Movie
set m:FavouriteMovie
return m

Check out the reference card neo4j.com/docs/stable/cypher-refcard/ and search for REMOVE.




回答2:


Labels not deleting are often caused by un-removed indexes. For example, if you have an index personID on the Person Node Label

DROP INDEX ON :Person(personID)


来源:https://stackoverflow.com/questions/28499175/unable-to-delete-node-labels-in-neo4j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!