Reputation: 43
According to the sample code at http://docs.neo4j.org/chunked/2.0.0-M03/rest-api-transactional.html I'm trying to use the MERGE statement.
But when I apply the following statement:
{
"statements": [
{
"statement": "MERGE (p:PERSON { identification }) ON CREATE p SET { properties } ON MATCH p SET { properties } RETURN p",
"parameters": {
"identification": {
"guid": "abc123xyz"
},
"properties": {
"lastName": "Doe",
"firstName": "John"
}
}
}
]
}
it gets back with the following 2 errors:
code: 42000, status: STATEMENT_EXECUTION_ERROR, message: Tried to set a property to a collection of mixed types. List(Map(guid -> abc123xyz))
code: 42001,
status: STATEMENT_SYNTAX_ERROR",
message: =' expected but
O' found\n\nThink we should have …
Can this not be done this way (yet) or am I missing something?
Thanks for your help
Daniel
Upvotes: 1
Views: 392
Reputation: 1798
The issue is that MERGE needs to know the keys you will search on in advance. Passing a map of parameters hides this.
To achieve the same, list each key explicitly. If you still want to pass them all in a single map, you can probably do something like: MERGE (p:Person {name: {merge_map}.name, email: {merge_map}.email})
.
Upvotes: 1
Reputation: 514
It seems you've discovered a bug. I've reported the issue here:
https://github.com/neo4j/neo4j/issues/975
Upvotes: 1
Reputation: 41706
Daniel,
I think you have to use SET differently, something like this:
MERGE (p:PERSON { identification })
ON CREATE p SET p={ properties }
ON MATCH p SET p={ properties }
RETURN p
But I'm not sure if that SET
overrides all your properties. So it might be that you have to specify them one by one.
{
"statements": [
{
"statement": "MERGE (p:PERSON { guid : {guid} })
ON CREATE p SET p.lastName={lastName},p.firstName={ firstName }
ON MATCH p SET p.lastName={lastName},p.firstName={ firstName }
RETURN p",
"parameters": {
"guid": "abc123xyz",
"lastName": "Doe",
"firstName": "John"
}
}
]
}
Upvotes: 0