Reputation: 13
Hi I am new to Neo4j and cypher, and I am trying to perform a probably straightforward match on property array. I am working in the desktop browser
I can create a node with a property array like so: CREATE (n:Example {names: ['a', 'b', 'c']})
I then try to match the names property for any one string like this: MATCH (n:Example {names: 'a'}) RETURN n But it returns no records
If I match the full array like this: MATCH (n:Example {names: ['a', 'b', 'c']}) RETURN n Then it returns the node like I want
I know how to match a node's one-string property to an array of strings, but mine is the other way around. How can I get the node from just matching one string of the node property's array of strings?
Thanks
Upvotes: 1
Views: 893
Reputation: 468
Try using the IN
clause to search within the array:
MATCH (n:Example) WHERE 'a' IN n.names RETURN n
Upvotes: 2