使用 Python 在 neo4j 中重置索引 [英] Reset Index in neo4j using Python

查看:77
本文介绍了使用 Python 在 neo4j 中重置索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在删除节点后重置索引,就像手动删除整个文件夹一样?

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

我正在使用 node.delete() 和relation.delete() 删除整个数据库,只是希望索引再次从 1 开始,而不是我实际停止的位置...

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

推荐答案

我假设您指的是节点和关系 ID 而不是 索引?

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.

稍微长一点的答案:一般来说,这些 ID 在您的应用程序中不应该具有任何相关性.在 Neo4j 邮件列表和 Stack Overflow 中对此进行了大量讨论,因为 ID 是内部工件,不应像主键一样使用.它的用途更类似于内存中的地址,如果您需要唯一标识符,最好考虑使用 UUID 之类的东西.

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.

这篇关于使用 Python 在 neo4j 中重置索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆