Clean-up schema, delete unused property and node types

Hi,

I have made some typos when creating properties (types) and would like to remove the property types listed in the browser. Is there a command for that?

Also, the schema has some relationships that are not in the graph, but appears in the graph schema. How to clean that up?

I cannot seem to find solution for this documented anywhere - except starting all over again.

br Kirsten

1 Like

Hi,
let me try to answer to what I think are two separate issues: the properties in your browser and the links in the schema.
About the browser :
my experience is that the neo4j browser only display the properties keys and the relationships types that are in your graph. The best way to remove some of them from the left panel is to remove them from your data.
Here is how to remove a property :

Here is how to remove a relationship :

About the schema
You said that it "has some relationships that are not in the graph, but appears in the graph schema*.
This is weird and is not supposed to happen.
Have you try running a query to confirm that these relationships are not in the graph ? If so, can you post it here ?

Hi,
Remove a property only works when at least a node have this property. Is it the only solution to recreate one node using all properties to "remove" them? If yes, what is the best way to have a list of all properties?
I made the mistake to delete all nodes before removing their properties. I have now a mess...
THX!

1 Like

The server caches a list of all properties & relationship types that ever have existed on nodes/relationships. I'm not sure if newer versions are different, but at least in older versions, the way to remove those was to perform a store copy using GitHub - jexp/store-utils: Utilities to compact, copy, fix, analyse Neo4j stores

Also the functions:
db.propertyKeys() and db.realtionshipTypes() will be of use. Run these before and after the store copy and you should see the properties & relationship types are removed after the store copy.

This post explains what is going on very well. It seems a bit counter intuitive to me. But since there will be unused properties anyway (spelling errors and property name changes during schema design and prototyping..etc), I decided to just ignore and not look at it. Making a new graph or copying it into a new one every time this happens is not really feasible.

1 Like

It would be really nice if there was an easy way to directly flush unused Labels and Properties.

I'm doing a Proof Of Concept and it's a tad embarrassing having half baked Labels and Properties exposed...

2 Likes

Agreed. It would be really nice to have some helper in the UI to flush unused stuff. Specifically so we don't have to delete and create new dbs.

4 Likes

No simple solution for broken unused property keys after 14 years? Seriously???

2 Likes

Still without solution this issue on neo4j browser ? :roll_eyes:

1 Like

Unlike labels and relationship types which have underlying meta-data that report the number of objects for each, there is no meta-data for property keys.

(quote from the posted link)

I wish this was more helpful. Is it really just a list behind a permissions wall? What's going on? Why can't we make this change already?

It appears to be a list that is so easy to call up, that it loads immediately when Browser loads. Even I can list them in three lines like this:

CALL db.propertyKeys()
YIELD propertyKey
RETURN propertyKey

and then I can find all of those that are currently used like this:

MATCH (n)
UNWIND keys(n) AS key
WITH DISTINCT key
RETURN key
ORDER BY key

so then I can combine them to create this:

MATCH (n)
UNWIND keys(n) AS key
WITH COLLECT(DISTINCT key) AS usedKeys

CALL db.propertyKeys() YIELD propertyKey

WHERE NOT propertyKey IN usedKeys
RETURN propertyKey
ORDER BY propertyKey

... but alas, Neo4j has no way to delete those that meet this criteria. The offered solutions are a time sink getting into an entirely different workflow to update a list... it is messy and redundant.

Neo4j is groundbreaking and intuitive in so many ways! I know you guys can do this!

3 Likes

well said, this should be possible to do, otherwise the suggestion dropdown usefulness is greatly dimished

1 Like