56

How can I add a label to an existing node using a Cypher query?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
cheesetaco
  • 721
  • 1
  • 6
  • 11

1 Answers1

100

That's in the reference docs, see http://docs.neo4j.org/chunked/stable/query-set.html#set-set-a-label-on-a-node, you need to use set to a add a label to a existing node:

match (n {id:desired-id})
set n :newLabel
return n
Pavan Kumar Varma
  • 1,413
  • 1
  • 14
  • 22
Stefan Armbruster
  • 39,465
  • 6
  • 87
  • 97
  • 6
    If you want to add a label to all nodes with another label, just do `match (n:ExistingLabel) set n :NewLabel`. The existing label is not removed. – ADTC May 12 '16 at 02:31
  • 7
    Old labels can be removed using: `match (n:OldLabel) remove n:OldLabel` – Thomas Bindzus Sep 16 '17 at 10:43