Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Add 3 distincts commands in CYPHER to add, replace and remove all labels on a node #2073

growak opened this Issue · 2 comments

2 participants


I need to do complex update node operation in a single transactional CYPHER query sent over HTTP to the REST endpoint. I didn't find any solution to REPLACE ou REMOVE all node labels in a CYPHER statement.

1) Add labels on a node (add labels to existing ones)
MATCH node
ADD node:Label1:Label2

2) Set labels on a node (replace all existing labels)
MATCH node
SET node:Label1:Label2

3) Set labels on a node (remove all labels from a node)
MATCH node
REMOVE node:*


Afaik there is no "remove all labels" operation.

Either you send multiple queries in the same request or the same tx

MATCH (n:Foo) REMOVE n:Foo

Or you will have to list them individually.
If you know the list of labels you can "work around" it by using foreach as a conditional:

WITH n,labels(n) as labels
FOREACH (l in [l2 in labels WHERE l2="Foo"] | REMOVE n:Foo)

or CASE WHEN to create a empty or one-element list

WITH n,labels(n) as labels
FOREACH (l in (CASE WHEN "Foo" in labels THEN ["dummy"] ELSE [] END) | REMOVE n:Foo)

What is your use-case for this?



Thank you for the quick answer.

I want to implement an update node method.
The method is taking a node id, a set of labels and a map of properties.
I don't know the previous values of the labels or the properties and I want to replace them by new values.

As I am writing this ... I am thinking that I will have the same problem with properties !


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.