从 Neo4j 中删除标签引用 [英] remove label reference from neo4j

查看:101
本文介绍了从 Neo4j 中删除标签引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在从电子表格导入大量数据时,我尝试使用标签约定,其中节点大写如This",关系标签被标记为THIS".在一个案例中,我不小心将关系标签格式用于一组节点.然后我删除了这些节点并使用正确的标签格式重新导入它们.(附带问题 - 有没有办法重命名我没有看到的可以避免删除/重新导入的标签?)

While importing a ton of data from spreadsheets, I attempted to use a labeling convention where nodes were capitalized like "This" and labels for relationships were labeled like "THIS". In one case, I accidentally used the relationship label format for a set of nodes. I then deleted those nodes and reimported them with the correct label format. (Side question - Was there a way to rename a label that I didn't see which could have avoided the delete/reimport?)

我的问题是,在内置的 Cypher 浏览器 (Neo4j 2.1.3) 中,正确和错误的标签都显示在节点列表中,即使有零个带有错误标签的节点.因此,虽然我成功删除了节点,但我不知道如何删除标签 - 不是从节点中删除,这很容易使用 REMOVE 命令,而是完全从数据库中删除.当它分配到的项目达到零时,它为什么不自动删除此标签?

My problem is that in the built-in Cypher browser (Neo4j 2.1.3), both the right and wrong labels show up on the node list, even though there are zero nodes with the wrong label. So while I successfully removed the nodes, I can't figure out how to remove the label - not from nodes, which is easy enough using the REMOVE command, but from the database entirely. Why didn't it remove this label automatically when the items it was assigned to reached zero?

更具体地说,我可以点击 MEASURES 的节点标签并触发此查询:

To be more specific, I can click on the node label for MEASURES and this query fires:

MATCH (n:`MEASURES`) RETURN n LIMIT 25

结果如下:

Returned 0 rows in 77 ms

我想从数据库中完全删除标签MEASURES",因为没有人使用它.如果您需要更多信息,请告诉我.

I would like to completely remove the label 'MEASURES' from the database since nothing is using it. Please let me know if you need further info.

推荐答案

我认为目前还没有一种内置方法可以从 Neo4j 数据库中完全删除不再使用的标签.我也对仍然出现在诸如 neo4j 浏览器 Web UI 等地方的过时标签感到恼火.

I don't think there is yet a builtin way to remove no-longer-used labels entirely from a neo4j DB. I have also been annoyed by obsolete labels still showing up in places like the neo4j browser web UI.

我知道一种删除它们的方法,但是如果您的数据库很大,它可能不切实际,并且它可能不完全安全.因此,如果您选择执行以下操作,则应确保备份了原始数据库(例如,您应该复制原始 graph.db 文件夹或重命名).

I know of one way to remove them, but it may not be practical if your DB is enormous, and it might not be totally safe. Therefore, if you choose to do the following, you should make sure you have your original DB backed up (for example, you should make a copy of your original graph.db folder or rename it).

技术其实很简单.您只需导出所有数据,关闭neo4j,删除或重命名原始graph.db文件,重新启动neo4j,然后重新导入数据.以下步骤假设您在 linux 环境中的 neo4j 安装文件夹中,并且 neo4j 未作为服务运行.

The technique is actually very simple. You just export all the data, shut down neo4j, delete or rename the original graph.db file, restart neo4j, and then re-import the data. The following steps assume that you are in your neo4j installation folder in a linux environment, and neo4j is not running as a service.

  1. 导出数据(作为将重新创建数据的 CYPHER 语句):

  1. Export the data (as CYPHER statements that will recreate the data):

./bin/neo4j-shell -c "dump" > mydump.cql

./bin/neo4j-shell -c "dump" > mydump.cql

关闭 neo4j(因为在数据库运行时删除或重命名 graph.db 是不安全的):

Shut down neo4j (as it is not safe to remove or rename graph.db while the DB is running):

./bin/neo4j 停止

./bin/neo4j stop

重命名当前的 graph.db 文件夹,以防万一您需要替换下面创建的新文件夹:

Rename the current graph.db folder, just in case you need to replace the new folder created below:

mv data/graph.db data/graph.db.archive

mv data/graph.db data/graph.db.archive

重启neo4j,会自动新建一个graph.db文件夹:

Restart neo4j, which will automatically create a new graph.db folder:

./bin/neo4j 启动

./bin/neo4j start

从转储中重新导入数据:

Re-import the data from the dump:

./bin/neo4j-shell -file mydump.cql

./bin/neo4j-shell -file mydump.cql

此时应该从任何地方删除过时的标签(您应该重新加载任何 neo4j 网页).

The obsolete labels should be gone at this point from everywhere (you should reload any neo4j web pages).

这篇关于从 Neo4j 中删除标签引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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