I recently migrated from 3.5.x to 4.0.x and am experiencing one issue that I'm trying to understand how to proceed. I created a simplified query below to exemplify the issue that occurs with fulltext search and NOT EXISTS(property) queries:
CALL db.index.fulltext.queryNodes('MessageIndex', 'Test') YIELD node as m, score
MATCH (u:User {id: "XXXXXX"})-[:likes]-(m)-[:from]-(o:Organization)
WHERE EXISTS(m.messageType) AND (NOT EXISTS (m.expiryTime) OR m.expiryTime > 1594407732 )
RETURN DISTINCT m as message
Error: NullCheckReferenceProperty(0,SlottedCachedPropertyWithPropertyToken(m,PropertyKeyName(expiryTime),0,false,55,2,NODE_TYPE,true)) (of class org.neo4j.cypher.internal.physicalplanning.ast.NullCheckReferenceProperty)
Version: Neo4j 4.0.6 Enterprise Server Driver: Scala
CALL db.index.fulltext.queryNodes('MessageIndex', 'Test') YIELD node as m, score
MATCH (u:User {id: "XXXXXX"})-[:likes]-(m)-[:from]-(o:Organization)
RETURN DISTINCT m as message
Yes, I tried that. It works which is how I isolated the NOT EXIST(node.property) clause as the issue. However, this is still the recommended syntax for checking if a property does not exist according to the 4.0.x documentation.
CALL db.index.fulltext.queryNodes('MessageIndex', 'Test') YIELD node as m, score
MATCH (u:User {id: "XXXXXX"})-[:likes]-(m)-[:from]-(o:Organization)
WHERE EXISTS(m.messageType)
RETURN DISTINCT m as message
CALL db.index.fulltext.queryNodes('MessageIndex', 'Test') YIELD node as m, score
MATCH (u:User {id: "XXXXXX"})-[:likes]-(m)-[:from]-(o:Organization)
WHERE EXISTS(m.messageType) AND m.expiryTime > 1594407732
RETURN DISTINCT m as message
I’ve reproduced the same in other queries that only by removing the NOT EXISTS (node.property) clause does the issue resolve.
CALL db.index.fulltext.queryNodes('MessageIndex', 'Test') YIELD node as m, score
MATCH (u:User {id: "XXXXXX"})-[:likes]-(m)-[:from]-(o:Organization)
WHERE EXISTS(m.messageType) AND (m.expiryTime IS NULL OR m.expiryTime > 1594407732 )
RETURN DISTINCT m as message
That worked, thank you! Is there a functional difference between node.property IS NULL and NOT EXISTS(node.property)? I'm just wondering why the docs recommend the latter.