我使用neo4j apoc工具从存储在hdfs上的json文件加载数据,文件内容示例如下:
{"id":"572911761","label":"Label1","nickName":"xxx","screenName":"xxx","userType":2}
{"id":"111117971217247","label2":"Label","nickName":"dada","userType":2}
{"id":"111112559184932","label3":"Label","nickName":"Kwok","screenName":"kwok","userType":2}
{"id":"1447694416","label":"Label4","nickName":"Sylar","screenName":"sylar","userType":2}
{"id":"111111154273959","label":"Label2","nickName":"Chan","screenName":"kmuhk","userType":2}
label
的字段是label of node in neo4j
,这意味着我想通过每行从文件中读取标签来设置动态标签,我的输入密码是:
CALL apoc.load.json("hdfs://hdp1:8020/apoc/graph/apoc_graph_20200422202753_0_nodes") yield value
call apoc.merge.node(value.label, {uid:value.uid}, {nickname:value.nickName,screen_name: value.screenName })
并且它执行错误,错误:
Neo.ClientError.Statement.SyntaxError
Neo.ClientError.Statement.SyntaxError: Query cannot conclude with CALL (must be RETURN or an update clause) (line 2, column 1 (offset: 98))
"call apoc.merge.node(value.label, {uid:value.uid}, {nickname:value.nickName,screen_name: value.screenName })"
^
寻求帮助,谢谢!
这里的错误消息非常有用,它表示查询的最后一行必须是对图的某种更新(如CREATE
或MERGE
(,或者是RETURN
语句。这里,我们有一个CALL
。
为了修复此问题,我们希望从apoc.merge.node
中生成合并节点,然后返回它:
CALL apoc.load.json("hdfs://hdp1:8020/apoc/graph/apoc_graph_20200422202753_0_nodes") yield value
CALL apoc.merge.node(value.label, {uid:value.uid}, {nickname:value.nickName,screen_name: value.screenName }) YIELD node
RETURN node