Find neo4j nodes where property is not set

2019-06-15 00:40发布

What's a cypher query to find a node where a property doesn't exist? 2 nodes: A = {foo: true, name: 'A'}, B = { name: 'B'}

need to find B because it doesn't have foo, i.e. B.foo is not set

标签: neo4j cypher
2条回答
孤傲高冷的网名
2楼-- · 2019-06-15 01:30
MATCH (f) WHERE f.foo IS NULL RETURN f
查看更多
Emotional °昔
3楼-- · 2019-06-15 01:34

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
查看更多
登录 后发表回答