问题
I am getting error Parameter maps cannot be used in MERGE patterns .How can I resolve this error.I am using the code below .I really appreciate any help.Thanks in Advance.
'MERGE (u:Person {names}) RETURN u ';
and
$data2='{
"names" : [{
"name" : "Keanu Reeves1",
"role" : "Neo1"
},
{
"name" : "Keanu Reeves2",
"role" : "Neo2"
},
{
"name" : "Keanu Reeves3",
"role" : "Neo3"
}]
}';
Entire code :
<?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);
?>
回答1:
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.
what you can do though is:
create constraint on (n:Label) assert n.id is unique;
MERGE (n:Label {id:{map}.id})
ON CREAETE SET n={map}
来源:https://stackoverflow.com/questions/28716699/parameter-maps-cannot-be-used-in-merge-patterns