我正在尝试创建以下查询:
MATCH (v:Value)
WHERE v.id = {valueId}
UNWIND keys(v) AS key
WITH v, key
WHERE key CONTAINS 'property.'
REMOVE key
但它现在失败,出现以下错误:
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"
^
此查询有什么问题以及如何解决?
答案 0 :(得分:2)
问题不在于密钥上的UNWIND,问题是您指定删除不在图形对象上的东西。
理想情况下,这必须成为:
MATCH (v:Value)
WHERE v.id = {valueId}
UNWIND keys(v) AS key
WITH v, key
WHERE key CONTAINS 'property.'
REMOVE v.key
不幸的是,这不起作用,因为属性键不能变化。
APOC的解决方法是在节点上设置已清理的地图:
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