Ian Kim
Ian Kim

Reputation: 170

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?

Upvotes: 0

Views: 323

Answers (1)

Luanne
Luanne

Reputation: 19373

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.

Upvotes: 3

Related Questions