apoc.create.setLabels
Procedure
apoc.create.setLabels(nodes ANY, labels LIST<STRING>)
- sets the given labels to the given NODE
values.
Non-matching labels are removed from the nodes.
Input parameters
Name | Type | Default | Description |
---|---|---|---|
nodes |
ANY |
null |
|
labels |
LIST<STRING> |
null |
The labels to set to the given |
Usage Examples
The examples in this section are based on the following sample graph:
CREATE (:Movie {title: 'A Few Good Men', genre: 'Drama'});
We can move the 'genre' property to a label and remove it as a property, as well as removing any other labels, by running the following query:
MATCH (n:Movie)
CALL apoc.create.setLabels( n, [ n.genre ] )
YIELD node
REMOVE node.genre
RETURN node;
node |
---|
(:Drama {title: "A Few Good Men"}) |
If we want to only add new labels and not remove existing ones, see apoc.create.addLabels