Update Movie Reviews

Update Movie Reviews

Write a query that returns a list pertaining to the movie, Toy Story. The list will contain the rating value for the RATED relationships for the movie with the title, Toy Story.

Once you have created the list, transform the values to integers.

How many list elements are transformed to the value 4?

Once you execute the query, enter the value below and click Check Answer.

  • ✓ 96

Hint

First write a MATCH clause to find the users and RATED relationships for the movie Toy Story.

Use a WITH clause to create the list containing the rating value of the RATED relationship.

Use a WITH clause to transform the elements of the list to Integer values.

Use UNWIND to process each element in the list and count the elements that have a value of 4.

How many list elements are transformed to the value 4?

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 (m:Movie)-[r:RATED]-()
WHERE m.title = 'Toy Story'
WITH collect(r.rating) AS Ratings
WITH Ratings, toIntegerList(Ratings) AS IntegerRatings
UNWIND IntegerRatings as x
WITH x WHERE x = 4
RETURN count(*)

How many list elements are transformed to the value 4?

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

Summary

In this challenge, you wrote a query that collects the ratings for a movie and transformed the values in the list. In the next lesson, you will learn about predicate functions in Cypher.