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.

How to filter results based on relationship properties

How can I filter the result based on relationship properties.?

Use case: Get all the MOVIES and PERSONS acted in them where role was NEO.
I tried the query as below

match (p:Person)-[a:ACTED_IN]->(m:Movie{title:'The Matrix'}) where a.roles = 'Neo' return p.name, m.title, a.roles

2 REPLIES 2

You were on the right track. Unfortunately the data set didn't make it easy if you're just starting out. If the property was a simply an int or a string you would have been just fine. But in the case of this data, the role isn't a string, it's actually a list. You can read up more on lists and data types here: https://neo4j.com/docs/cypher-manual/current/syntax/lists/.

Here's the fix to your query:

match (p:Person)-[a:ACTED_IN]->(m:Movie{title:'The Matrix'}) 
where a.roles = ['Neo']
return *

Thanks Michael, it works.