Create 正在工作,但在 neo4j 后参数中的 MERGE 有错误 [英] Create is working but MERGE in neo4j post params has error

查看:15
本文介绍了Create 正在工作,但在 neo4j 后参数中的 MERGE 有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码.还有一个我收到此错误.我该如何解决?

I have the code below .And a I am getting this error.How can I fix it ?

顺便说一句,同样的 CREATE 正在工作:

BTW CREATE for the same is working:

 <?php

$data2='{
  "names" : [{
    "name" : "Keanu Reeves1",
    "role" : "Neo1"
  },
  {
    "name" : "Keanu Reeves2",
    "role" : "Neo2"
  },
  {
    "name" : "Keanu Reeves3",
    "role" : "Neo3"
  }]
}';


$data ='MERGE (u:Person {names}) RETURN u';


$data2=json_decode($data2);


$data = array("query" =>$data,"params"=>$data2 );
$data_string = json_encode($data);


print_r($data_string);
//print_r($data2);
$ch = curl_init('http://192.....:7474/db/data/cypher');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($data_string))
);

print_r ($ch);

$result = curl_exec($ch);

print_r($result);

?>

错误:

参数映射不能在 MERGE 模式中使用

Parameter maps cannot be used in MERGE patterns

{ "message" : "Parameter maps cannot be used in MERGE patterns (use a literal map instead, eg. "{id: {param}.id}") (line 1, column 17)
"MERGE (u:Person {names}) RETURN u"
 ^", "exception" : "SyntaxException", "fullname" : "org.neo4j.cypher.SyntaxException"

推荐答案

不幸的是,由于查询计划的原因,这些地图无法在合并中使用.就像在 sql 中拥有动态表列一样.

Unfortunately due to reasons for query planning those maps cannot be used in merge. Same as if you would have dynamic table columns in sql.

你可以做的是:

create constraint on (n:Label) assert n.id is unique;

MERGE (n:Label {id:{map}.id})
ON CREATE SET n={map}

这篇关于Create 正在工作,但在 neo4j 后参数中的 MERGE 有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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