Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete labels in neo4j?

Tags:

neo4j

How to delete labels in neo4j? Actually I deleted all nodes and relationships, then I recreated the movie database and still the labels I created before appeared on the webinterface. I also tried to use a different location for the database and even after an uninstall and reinstall the labels still appeared. Why? Where are the labels stored? After the uninstall the programm, the database folder and the appdata folder were deleted.

How to reproduce? Install neo4j -> use the movie database example -> create (l:SomeLabel {name:"A freaky label"}) -> delete the node -> stop neo, create new folder -> start neo -> create movie shema -> match (n) return (n) -> SomeLabel appears, even if you changed the folder or make an uninstall / install.

Is there a way to delete labels even if there is no node with it?

like image 720
Matthias Baumgart Avatar asked Feb 24 '14 09:02

Matthias Baumgart


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 a record 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.


2 Answers

There isn't at the moment (Neo4j 2.0.1) a way to explicitly delete a label once it has been created. Neo4j Browser will display all labels which are reported by the REST endpoint at:

http://localhost:7474/db/data/labels

Separately, the Neo4j Browser sidebar which displays labels doesn't properly refresh the listing when it loses connection with Neo4j. A web browser reload should work.

Lastly, there was a bug in Neo4j Browser's visualization which would display all labels for which a style had been created. If using a version of Neo4j which has the bug, you can clear the styling by clicking on "View Stylesheet" in the property inspector, then clicking the fire extinguisher icon. All of that needs usability improvement, admittedly.

Cheers, Andreas

like image 130
akollegger Avatar answered Sep 20 '22 16:09

akollegger


This seems to be worked out by version 2.3.0.

As an example, suppose we had created a movie in the data browser such as:

CREATE(m:Movie:Cinema:Film:Picture{title:"The Matrix"}) 

We could query it with

MATCH(m:Movie) WHERE m.title = "The Matrix" RETURN m 

It would have 4 labels: Movie, Cinema, Film, and Picture

To remove the Picture label from all movies:

MATCH(m:Movie) REMOVE m:Picture RETURN m 

To remove the Picture label from only that one movie:

MATCH(m:Movie) WHERE m.title = "The Matrix" REMOVE m:Picture RETURN m 
like image 27
ThisClark Avatar answered Sep 19 '22 16:09

ThisClark