简体   繁体   English

如何使用 spring 数据 neo4j 将给定的 label 添加到给定节点?

[英]How to add a given label to given node by using spring data neo4j?

I use the spring data neo4j @query to add a label to a node, but there are some syntaxes.我使用 spring 数据 neo4j @query 将 label 添加到节点,但有一些语法。 How can I transfer param correctly?如何正确传输参数?

Such as:如:

@Query("MATCH (st) WHERE st.originId = $originId SET st:$label RETURN st")  
public Node addLabel(String originId, String label);

@Query("MATCH (st) WHERE st.originId = $originId SET st:label RETURN st") 
public Node addLabel(String originId, @Param("label") String label);

@Query("MATCH (st) WHERE st.originId = $originId SET st:$1 RETURN st")
public Node addLabel(String originId, String label);

All of the above statements have errors.The compiler told me there was an error in ':'.以上所有语句都有错误。编译器告诉我':'中有错误。

So, What's the correct statements?那么,正确的说法是什么?

At the moment, cypher does not support assigning dynamic node labels.目前,cypher 不支持分配动态节点标签。 You will need to use the APOC library:您将需要使用 APOC 库:

MATCH (st) WHERE st.originId = $originId
CALL apoc.create.addLabels( [st], [$label​]) YIELD node
RETURN distinct 'done'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM