Using the CONTAINS Predicate

Roles containing dog?

Write and execute a query to return the name of the person, their role, and the movie title where the role played by the actors or director had a value that included 'dog' (case-insensitive)? That is, the role could contain "Dog", "dog", or even "DOG".

Once you executed, enter the number of rows returned below and click Check Answer.

  • ✓ 27

Hint

A Person node has an ACTED_IN or DIRECTED relationship to a Movie. Some of these relationships have a property named role. You should use toLower() or toUpper() to test the string.

Once you have entered the answer, click the Try Again button below to continue.

Solution

You can run the following query to find the answer:

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

How many rows does it return?

Once you have entered the answer, click the Try Again button below to continue.

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.