Find Neo4j nodes where the property is not set

╄→гoц情女王★ 提交于 2019-12-10 12:29:08

问题


Using Cypher, how can I find a node where a property doesn't exist?

For example, I have two nodes:

A = {foo: true, name: 'A'},  B = { name: 'B'}

Now I'd like to find B, selecting it on the basis of not having the foo property set. How can I do this?


回答1:


As Michael Hunger mentioned

MATCH (n) WHERE NOT EXISTS(n.foo) RETURN n

On older versions of Neo4j you can use HAS:

# Causes error with later versions of Neo4j
MATCH (n) WHERE NOT HAS(n.foo) RETURN n



回答2:


MATCH (f) WHERE f.foo IS NULL RETURN f


来源:https://stackoverflow.com/questions/35400674/find-neo4j-nodes-where-the-property-is-not-set

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!