cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

match with an OR expression for the node label

Hi! 

I found from the documentation that the below syntax should work. However when I try it in neo4j browser, it gives me Neo.ClientError.Statement.SyntaxError. Is this syntax no longer supported by cypher? Thanks!

MATCH (n:Movie|Person)
RETURN n.name AS name, n.title AS title

#neo4j

1 ACCEPTED SOLUTION

The link is to the cypher 5.0 documentation. I could not find it in the 4.x documentation (the version can be selected from the drop down at the top left side of the window). I believe the ability to use an OR operator for label expressions for nodes was added in 5.0.  It did exist for relationships types in 4.0.  Maybe that is what you remember. The following is from the 5.0 release notes:

Improved label expressions in MATCH clauses. 
Nodes and relationships can be filtered using more sophisticated label 
and type boolean expressions such as & for logical AND (V:L1&L2), 
| for logical OR (V:L1|L2), ! for negation (V:!L4), % for any (V:%) 
and () for grouping (V:(L1&L2)|(L3& !L4)).

I also tested it in 5.0. It worked, but did not work in 4.4.10. 

https://neo4j.com/release-notes/database/neo4j-5/

View solution in original post

2 REPLIES 2

The link is to the cypher 5.0 documentation. I could not find it in the 4.x documentation (the version can be selected from the drop down at the top left side of the window). I believe the ability to use an OR operator for label expressions for nodes was added in 5.0.  It did exist for relationships types in 4.0.  Maybe that is what you remember. The following is from the 5.0 release notes:

Improved label expressions in MATCH clauses. 
Nodes and relationships can be filtered using more sophisticated label 
and type boolean expressions such as & for logical AND (V:L1&L2), 
| for logical OR (V:L1|L2), ! for negation (V:!L4), % for any (V:%) 
and () for grouping (V:(L1&L2)|(L3& !L4)).

I also tested it in 5.0. It worked, but did not work in 4.4.10. 

https://neo4j.com/release-notes/database/neo4j-5/

This is indeed a new feature in v5