neo4j-如何设置带有属性值的标签 [英] neo4j - how to set label with property value
本文介绍了neo4j-如何设置带有属性值的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的节点没有标签,但是有一个NodeType属性
I have nodes without label but a property NodeType
是否可以使用NodeType属性的值设置这些节点的标签?
Is there a way to set the label of those nodes with the value of the NodeType property?
谢谢!
推荐答案
否,当前无法使用变量定义标签.
No, currently there is no possibility to define a label with a variable.
您必须在应用程序中执行此操作,方法是获取要在其上添加标签的所有节点,然后发送Cypher查询以添加该标签.
You'll have to do it in your application by fetching all nodes that you want to add a label on it and sending a Cypher Query to add this label.
PHP中的简单示例:
A quick example in PHP :
$nodes = $client->sendCypherQuery('MATCH (n) WHERE n.nodeType = "MyType" RETURN n');
foreach ($nodes as $node) {
$label = $node->getProperty('nodeType');
$id = $node->getId();
$client->sendCypherQuery('MATCH (n) WHERE id(n) = '.$id.' SET n :'.$label;
}
这篇关于neo4j-如何设置带有属性值的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文