如何在neo4j中使用密码创建多个节点 [英] How to create multiple nodes with cypher in neo4j

查看:65
本文介绍了如何在neo4j中使用密码创建多个节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用一个密码查询创建多个断开连接的节点

I would like to create multiple disconnected nodes using a single cypher query

文档说:

使用参数为其属性创建多个节点.通过为Cypher提供一系列地图,它将为每个地图创建一个节点.

Create multiple nodes with a parameter for their properties. By providing Cypher an array of maps, it will create a node for each map.

CREATE (n { props })
RETURN n

在neo4j rest Web控制台中,我尝试了(其他方面)

In the neo4j rest web console I tried (amongst many other things)

CREATE (n [{a:1,b:2}, {a:1,b:2}]) RETURN n

但是收到此错误

无效的输入'[':预期的空格,注释,节点标签,MapLiteral,参数')'或关系模式(第1行,第11列)创建(n [{a:1,b:2},{a:1,b:2}])返回n"

Invalid input '[': expected whitespace, comment, node labels, MapLiteral, a parameter, ')' or a relationship pattern (line 1, column 11) "CREATE (n [{a:1,b:2}, {a:1,b:2}]) RETURN n"

是否可以做我正在尝试的事情,如果可以,怎么做?

Is it possible to do what I am trying and if so how?

推荐答案

它必须是http-api或java-api的参数.

It has to be a parameter either to the http-api or the java-api.

CREATE (n { props })
RETURN n

{props:[{a:1,b:2}, {a:1,b:2}]}

或者您甚至可以对文本数组使用 foreach

Or you can use foreach even with literal arrays

FOREACH (props IN [{ a:1,b:2 }, { a:1,b:2 }]| 
         CREATE ({ a:props.a,b:props.b }))

这篇关于如何在neo4j中使用密码创建多个节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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