Using the CONTAINS Predicate

Roles containing dog?

Find the roles that contain the word "dog" (case-insensitive).

Update the query to filter by the role property of the ACTED_IN relationship.

cypher
MATCH (p:Person)-[r:ACTED_IN]->(m:Movie)
WHERE ??????
RETURN p.name, r.role, m.title

How many rows are returned?

Hint

You should use toLower() or toUpper() to test the string.

The clause CONTAINS can be used to test if a string contains a specific value.

Solution

The answer is 24

You can run the following query to see the result:

cypher
MATCH (p:Person)-[r:ACTED_IN]->(m:Movie)
WHERE toLower(r.role) CONTAINS "dog"
RETURN p.name, r.role, m.title

Summary

In this challenge, you wrote and executed a basic query to test if a string is contained in a property value.

In the next lesson, you will learn more about using patterns in your queries.