更改neo4j中的节点标签 [英] Change node label in neo4j

查看:1498
本文介绍了更改neo4j中的节点标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个带有错误标签的节点.
有什么方法可以在不重新创建节点标签或关系类型的情况下进行更改? 我已经尝试过

I have created a node with a wrong label.
Is there any way to change node label or relationship type without re-creating it? I have tried something like

在nd(n)= 14 SET n.Labels ='Person'的地方匹配

MATCH n WHERE Id(n)=14 SET n.Labels = 'Person'

但这是错误的...

推荐答案

您可以更改与标签关联的节点,但是不能更改关系的类型.从概念上讲,如果您将鸡从一个鸡舍中取出并放入另一个鸡舍,则您并没有改变鸡的成分.但是当您将鸡从烤箱中取出放到嘴里时,它已经不再是鸡了(模棱两可).您可以决定叫猫 Whiskers 而不是 Charlie ,但是如果您决定要用水蟒代替宠物而不是猫,那将无助于为它起个新名字.同样,一个节点可以是不同标签的成员,并且可以保留相同的节点,但是关系的类型是本构的.因此:您可以根据需要添加和删除标签,但是如果您想要不同的关系类型,那么您想要的实际上是不同的关系.这也是为什么关系只有一种类型,而一个节点却可以有很多标签的原因.

You can change the nodes associated with a label but you can't change the type of a relationship. Conceptually, if you take your chicken out of one coop and put it in another you haven't altered the substance of the chicken. But by the time you take the chicken out of the oven and put it in your mouth, it's not a chicken anymore (except equivocally). You can decide to call your cat Whiskers instead of Charlie, but if you decide you want an anaconda for a pet instead of a cat, it doesn't help to give the cat a new name. Similarly, a node can be a member of different labels and remain the same node, but a relationship's type is constitutive. So: you can add and remove labels as you please, but if you want a different relationship type then what you want is really a different relationship. This is also why a relationship has exactly one type, but a node can have many labels.

标签是节点的任意集合或袋子.已经给出了换袋的语法,但是为了完整性:

Labels are arbitrary sets or bags of nodes. The grammar for changing bags has already been given, but for completeness:

MATCH (n)
WHERE ID(n) = 14 
REMOVE n:Whiskers
SET n:Charlie

MATCH (petless_and_unhappy)-[whiskers:CAT]->(petful_and_unhappy)
DELETE whiskers
CREATE (petless_and_unhappy-[sir_hiss:ANACONDA]->(peftul_and_happy)

这篇关于更改neo4j中的节点标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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