Predicate function understanding : exists()

Hello Team,

Please guide me or help me to make it easier for me to understand the exists() function using below example.

MATCH (a),(b)
WHERE exists( AND NOT exists(
RETURN AS a_name, AS b_name, exists( AS b_has_name, AS c_name, exists( AS c_has_name , a , b ,c
ORDER BY a_name, b_name, c_name LIMIT 1


Thanks in Advance!

Best Regards

Nodes in the graph (such as a and b in your query) have properties that hold data; however, if is not required that all nodes hold the same properties.
Given a node, you can use the exists() function to determine if a given property exists on a node. The exists() function returns true or false depending on if the node contains the supplied property.

So as you can see in your result, node a contains a property called name with a value of 'Akshat' and the exists( returns true. The node b does not contain a property called name so when retrieving it, it returns null and the exists function returns false. Note that node property names are case-sensitive, so even though node b contains a property called "Name" exists still returns false.

I hope this helps clarify.

Hello Brant,

Thanks a lot for the quick information.

Please find the below screenshot:==> I am expecting null as an output.




Best Regards

Null is not going to be a result unless it's actually a value, such as if you had MATCH (n:Person) RETURN n.nonExistentProperty.

When filtering, if there are no rows left (everything has been filtered out, or otherwise no entries found) you will have an empty result set, no records/rows, it won't be a null return.