Reputation: 25780
I'm trying to create the following query:
MATCH (v:Value)
WHERE v.id = {valueId}
UNWIND keys(v) AS key
WITH v, key
WHERE key CONTAINS 'property.'
REMOVE key
but it fails right now with the following error:
org.neo4j.driver.v1.exceptions.ClientException: Unexpected end of input: expected an identifier character, whitespace, node labels, '{', a property map, a relationship pattern, '.' or '(' (line 1, column 122 (offset: 121))
"MATCH (v:Value) WHERE v.id = {valueId} WITH v UNWIND keys(v) AS key WITH v, key WHERE key CONTAINS 'property.' REMOVE key"
^
What is wrong with this query and how to fix it?
Upvotes: 0
Views: 2039
Reputation: 20185
The issue is not the UNWIND on the keys, the issue is that you specify to remove something not on a graph object.
Ideally this would have to become :
MATCH (v:Value)
WHERE v.id = {valueId}
UNWIND keys(v) AS key
WITH v, key
WHERE key CONTAINS 'property.'
REMOVE v.key
Unfortunately this doesn't work as the property key cannot be variable.
A workaround with APOC is to set a cleaned map on the node :
MATCH (v:Value)
WHERE v.id = {valueId}
SET v = apoc.map.clean(properties(v), filter(x IN keys(v) WHERE x CONTAINS 'property.'), [])
RETURN v
Upvotes: 3