rorymadden
rorymadden

Reputation: 954

Delete property from Neo4j graph

I need to delete some node properties from my graph. Following the cypher guidelines I have tried the following:

START n=node(1)
DELETE n.property
RETURN n

I get an error message:

Expression `Property` yielded `true`. Don't know how to delete that.

I can replicate this on console.neo4j.org. How are you supposed to delete the property of a node?

Upvotes: 11

Views: 19583

Answers (4)

Kaan
Kaan

Reputation: 5794

The goal is:

to delete some node properties from my graph

If your node type is "Thing", and you want to remove a property called "size", you can remove that property from all of the nodes with this:

MATCH (t:Thing)
REMOVE t.size

Upvotes: 0

Kasun Wanniarachchi
Kasun Wanniarachchi

Reputation: 544

When you want to remove relationship property out of multiple relationships between the nodes.

MATCH (a:Application {name:'A'})-[r:REQUEST_TO]-(d:Application {name:'B'})
WHERE ID(r) = 684
REMOVE r.property

Upvotes: 0

carvilsi
carvilsi

Reputation: 175

Just another example.

For Neo4j 3.0, given a node with property keys, name and age, to delete the age property is also valid:

Create the node:

CREATE (n {name:'Andres', age:25}) return n

Delete the property key age:

MATCH (andres { name: 'Andres' }) REMOVE andres.age RETURN andres

From Neo4j 3.0 documentation https://neo4j.com/docs/developer-manual/current/cypher/#query-remove

Upvotes: 13

khituras
khituras

Reputation: 1091

What version of Neo4j are you using? Since Neo4j 2.0 (I'm not sure what milestone exactly, tried it with M03), properties are not "deleted" anymore but "removed":

START n=node(1)
REMOVE n.property
RETURN n

Should work with Neo4j 2.x.

This is also reflected in the documentation. On the right side of the page (perhaps after some loading time) you have a pull-down menu for choosing your Neo4j version. When you go to the DELETE documentation and choose the 2.0.0-M03 milestone, you will notice that the "Delete a property" menu point disappears (link to the M03 documentation on DELETE: http://docs.neo4j.org/chunked/2.0.0-M03/query-delete.html).

Instead, the documentation for 2.0.0-M03 on REMOVE (here: http://docs.neo4j.org/chunked/2.0.0-M03/query-remove.html) does now list the "Remove a property" section.

Upvotes: 16

Related Questions