简体   繁体   中英

Cypher: “WHERE node.property?” not compatible with IN operator?

It seems that trying to use the default-false-if-missing syntax ( WHERE node.property? = ... ) does not work when combined with the IN operator:

$ start n=node:node_auto_index(lc_name="aspirin")
> match n--a--o
> where n.isProcPhen? IN [true, false]  // n doesn't have this property
> return count(o);

=> count(o):
=> 0

But if I don't use IN , then it seems to work properly:

$ start n=node:node_auto_index(lc_name="aspirin")
> match n--a--o
> where n.isProcPhen? = false
> return count(o);

=> count(o):
=> 5729

Is there another way to do this, or am I out of luck?

Do any of the 5729 results actually have this property isProcPhen?

If they don't have the property, then the query works as expected because n.isProcPhen? = false will evaluate to true since the property is missing

See http://docs.neo4j.org/chunked/stable/query-operators.html

However, with IN, you are only matching nodes that have values true or false. The nodes that don't have this property will have n.isProcPhen? evaluate to null.

I suspect if you change your query to n.isProcPhen? IN [true,false,null] you'll get back 5729 results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM