How to get nodes in neo4j based on property value

use*_*919 1 neo4j cypher

I have created some nodes with a property called: color. I haven't assigned any values to this property. Now I want to write a query to get all the nodes which have this property "NULL".

My query is this:

  MATCH (n:Image) WHERE n.color='' RETURN n
Run Code Online (Sandbox Code Playgroud)

But this returns nothing. How can I get all the nodes which belong to the label:Image and have the property:Color empty?

I also tried this with no luck:

MATCH (n:Image) WHERE n.color IS NULL RETURN n
Run Code Online (Sandbox Code Playgroud)

Thanks D.

Lua*_*nne 5

Null不是有效的属性值 - 如果未分配值或显式指定null,则该属性在节点上不存在.

你可以使用其中之一

MATCH (n:Image) where not(has(n.color)) return n
Run Code Online (Sandbox Code Playgroud)

检查属性是否存在于节点上或简单地

MATCH (n:Image) where n.color IS NULL
Run Code Online (Sandbox Code Playgroud)

根据以下注释,空String与缺少的属性/ null值不同.