Reputation: 367
Neo4j has two different clauses to find value in an array, ANY and IN. Please explain, how they are different as both are used to filter the data by checking if, the specified value is present in the array or not.
Query#1 : MATCH (n) WHERE any(color IN n.liked_colors WHERE color = 'yellow') RETURN n
Result#1: Node with name Eskil
Query#2 : Match (n) where 'yellow' in n.liked_colors return n
Result#2: Node with name Eskil
If both query return same results then where is the diffrence.
Upvotes: 0
Views: 659
Reputation: 30417
In your simple example case the results are the same.
However any()
allows more complex means of filtering, especially when we aren't using this to simply detect membership of a known value in a list:
MATCH (n:Person)
WHERE any(color in n.liked_colors WHERE (n)<-[:KNOWS|MARRIED*]-(other:Person {eyes:color}))
Find a person where for any of their liked colors, we can traverse the given pattern to find another person with eyes of that color.
Upvotes: 0