Set label from a nodes property

2019-08-03 18:00发布

How can i add a label for a node from one of the nodes properties ? I have a large CSV-file with a label in one column. With the LOAD CSV command its not possible to set a nodes label from a CSV-column value. Is there anoter way ?

标签: neo4j cypher
1条回答
聊天终结者
2楼-- · 2019-08-03 19:03

The APOC procedures Neo4j plugin contains some useful procedures for helping to refactor a graph (https://neo4j-contrib.github.io/neo4j-apoc-procedures/#_graph_refactorings)

For your needs, you can use the following procedure :

CALL apoc.create.addLabels( node, [ properties ] )

Here an example :

MATCH (n:Movie)
CALL apoc.create.addLabels( id(n), [ n.genre ] ) YIELD node
REMOVE node.genre
RETURN node

For installing APOC extension, download the .jar file regarding your Neo4j version, place it into /plugins folder in your Neo4j installation, then restarts Neo4j.

查看更多
登录 后发表回答