I've inherited a Neo4j database which is massive to say the least. I've been looking into it and noticed we store a large string in each node that is not used.
Let's say we have a few million nodes called Post
and each Post
has Text
. I'd like to remove Text
from each Post
in the entire database. Can someone point me down the path of doing so via Cypher?
Also, how would you recommend safely doing this? Should I back up the entire instance incase something goes wrong? Or does Neo4j have a transactional history I can rely on?
Neo4j does not allow NULL in the property so you can REMOVE Text from Post. Here is the syntax:
MATCH (p:Post)
REMOVE p.text
However, you said you have a massive database so I would recommend to remove it by batch.
CALL apoc.periodic.iterate(
"MATCH (p:Post) RETURN p",
"REMOVE p.text",
{batchSize:10000, parallel:true})
It would create batches of 10k Post nodes then remove the property text then run it in parallel.
In any mass updates that you do, it is highly recommended to create a backup of the database.