As a newbie, I've managed to create some relationship types as node labels. For example, the relationship type ':NESTING' also exists as the node label 'NESTING'. Selecting them in the Database Information panel confirms NO nodes with the label. I've tried multiple ways to get rid of the invalid labels, to no avail.
Can some kind soul please show me how it's done?
TIA,
Paolo
To remove labels from your nodes, you can use "REMOVE"
MATCH (n:NESTING)
REMOVE n:NESTING
Although if they are still appearing in browser, try refreshing you browser. Alternativlty if it still shows up when you're calling call db.schema there might be some constraints or indices for the label.
To list the constraints you can use
Hi Max, this doesn't work because, as I mentioned, there are NO nodes with that label. I need the syntax to remove a label that has NO nodes. The syntax you provide will remove a label from a node that already has the label applied.
[/quote]Yes, @glilienfield, and there were none.
Are you saying that syntax should remove the "orphan" label? How can it? There is no node to return the match result?
Hi @ameyasoft,
I'm really not understanding the responses. I'm talking about removing an orphan label, NOT an orphan node! Whilst one can't create a label without using a node (AFAIK), you can remove the label from the node (or delete all the nodes with that label), and the label still seems to remain - or is that not true?
I just tested in my local environment. This was my experience.
I create a node with a new label. It showed up in the list of labels in Neo4j Desktop. I then delete the one node that had that label and the label was removed from the list in Desktop.
I again created a node with a new label and it showed in the list of labels. I then created an index on a property with the label. I then deleted the node with the label and it did not remove the label from the labels list in desktop.
I then deleted the index and the label was removed fro the list.
It looks like having an index or a constraint on a property with label, results in the label being listed even though no nodes exists with the label. This make sense to me.
Thanks, @glilienfield,
I created a v5.5 instance on my local machine and it behaves as you said for the simple example you provided. I then tried the same on our v4.4 production system and it also worked there Indeed, I added a constraint rather than an index and it still worked. For the orphan label(s) we still apparently have (we haven't restarted our production server) it looks like an anomalous situation "shrouded in the mists of time". I'm happy to "put this one to bed".