Knowledge Base

Using Cypher and APOC to move a property value to a label

Commencing with Neo4j 3.0 and the introduction of stored procedures as well as APOC one can utilize the stored procedure apoc.create.addLabels to move a property to a label with Cypher as follows

// create a node with property studio
create (n:Movies {name: 'A Few Good Men', studio: 'Warner Brothers'})
// move the 'studio' property to a label and remove it as a property
MATCH (n:Movies)
call apoc.create.addLabels([ id(n) ], [ n.studio ]) yield node
with node
remove node.studio
return node