Set label from a nodes property

会有一股神秘感。 提交于 2019-12-24 12:10:25

问题


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

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