以下REST API批处理失败:
POST http://localhost:7474/db/data/batch [{"method":"POST","to":"index/node/name uniqueness=get_or_create","body":{"key":"name","value":"Person1","properties":{"Type":"PERSON"}},"id":1},
{"method":"POST","to":"index/node/name?uniqueness=get_or_create","body":{"key":"name","value":"Person2","properties":{"Type":"PERSON"}},"id":2},
{"method":"POST","to":"{1}/relationships","body":{"type":"Knows","to":"{2}","data":{"Since":"2012"}},"id":3}]
500内部服务器错误。
由于某些原因,当使用uniqueness = get_or_create时,似乎无法使用{1}和{2}引用批处理中的节点。或者我错过了什么?
答案 0 :(得分:1)
您可以在第三个操作中使用cypher并使用索引查找来访问新创建的节点。
start n1=node:name(name={name1}), n2=node:name(name={name2})
create n1-[:Knows {props}]->n2
带参数
{
"query":"start n1=node:name(name={name1}), n2=node:name(name={name2}) create n1-[:Knows {props}]->n2",
"params":{"name1":"Person1","name2":"Person2","props":{"Since":"2012"}}
}