Reset Index in neo4j using Python

耗尽温柔 提交于 2019-12-31 03:47:07

问题


Is there a possibility to reset the indices once I deleted the nodes just as if deleted the whole folder manually?

I am deleting the whole database with node.delete() and relation.delete() and just want the indices to start at 1 again and not where I had actually stopped...


回答1:


I assume you are referring to the node and relationship IDs rather than the indexes?

Quick answer: You cannot explicitly force the counter to reset.

Slightly longer answer: Generally speaking, these IDs should not carry any relevance within your application. There have been a number of discussions about this within the Neo4j mailing list and Stack Overflow as the ID is an internal artifact and should not be used like a primary key. It's purpose is more akin to an in-memory address and if you require unique identifiers, you are better off considering something like a UUID.




回答2:


You can stop your database, delete all the files in the database folder, and start it again.

This way, the ID generation will start back from 1.

This procedure completely wipes your data, so handle with care.

Now you certainly can do this using Python.

see https://stackoverflow.com/a/23310320



来源:https://stackoverflow.com/questions/15669683/reset-index-in-neo4j-using-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!