apoc.create.addLabels

Procedure

apoc.create.addLabels(nodes ANY, labels LIST<STRING>) - adds the given labels to the given NODE values.

Signature

apoc.create.addLabels(nodes :: ANY, labels :: LIST<STRING>) :: (node :: NODE)

Input parameters

Name Type Default Description

nodes

ANY

null

nodes can be of type STRING (elementId()), INTEGER (id()), NODE or LIST<STRING | INTEGER | NODE>.

labels

LIST<STRING>

null

The labels to add to the given NODE values.

Output parameters

Name Type

node

NODE

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 by running the following query:

MATCH (n:Movie)
CALL apoc.create.addLabels( n, [ n.genre ] )
YIELD node
REMOVE node.genre
RETURN node;
Table 1. Results
node

(:Movie:Drama {title: "A Few Good Men"})