问题
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 ?
回答1:
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.
来源:https://stackoverflow.com/questions/51150474/set-label-from-a-nodes-property