Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete property from Neo4j graph

Tags:

neo4j

cypher

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?

like image 332
rorymadden Avatar asked Aug 02 '13 06:08

rorymadden


People also ask

How do I remove a property from neo4j?

Remove all properties REMOVE cannot be used to remove all existing properties from a node or relationship. Instead, using SET with = and an empty map as the right operand will clear all properties from the node or relationship.

How do I delete everything on neo4j?

Deleting Nodes and Relationships Deleting all nodes and relationships in a Neo4j database is very simple. Here is an example that does just that: MATCH (n) DETACH DELETE n; The DETACH keyword specifies to remove or “detach” all relationships from a particular node before deletion.

How do I delete a particular relationship in neo4j?

Deleting relationship is as simple as deleting nodes. Use the MATCH statement to match the relationships you want to delete. You can delete one or many relationships or all relationships by using one statement.

How do I delete a particular node in neo4j?

In Neo4j to delete a node or relations between nodes you have to use DELETE clause. To delete any node you need DELETE clause with the MATCH statement, the MATCH statement data will find the specific node and whichever node is matched with the statement that node will be vanished.

How to delete a node in Neo4j?

Neo4j Delete Node Last Updated : 23 Aug, 2019 In Neo4j to delete a node or relations between nodes you have to use DELETE clause. To delete any node you need DELETE clause with the MATCH statement, the MATCH statement data will find the specific node and whichever node is matched with the statement that node will be vanished.

What is the use of remove clause in Neo4j CQL?

The REMOVE clause is used to remove properties and labels from graph elements (Nodes or Relationships). The main difference between Neo4j CQL DELETE and REMOVE commands is −

How do I Choose my Neo4j version?

On the right side of the page (perhaps after some loading time) you have a pull-down menu for choosing your Neo4j version.

How to delete a node in a table without deleting relationships?

Remember that you cannot delete a node without also deleting relationships that start or end on said node. Either explicitly delete the relationships, or use DETACH DELETE. 2. Delete single node To delete a node, use the DELETE clause. Table 1. Result 3. Delete all nodes and relationships


2 Answers

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.

like image 134
khituras Avatar answered Oct 15 '22 02:10

khituras


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

like image 37
char Avatar answered Oct 15 '22 01:10

char