In this Challenge, you will be working with the data you previously imported with the Data Importer.
This challenge has 2 steps:
-
Transform the Movie properties to lists.
-
View the types stored in the graph.
Step 1: Transform the Movie properties to lists
Execute this code in the sandbox on the right to view the multi-value properties of the Movie nodes.
MATCH (m:Movie)
RETURN m.countries, m.languages, m.genres
Copy this code into the sandbox on the right, modify it to transform the three multi-value properties (languages, countries, genres) of Movie nodes, and execute it:
MATCH (m:Movie)
SET m.countries = split(coalesce(m.countries,""), "|"),
// add the transformation for the languages and genres properties
Your code should have set 279 properties.
Step 2: View the types stored in the graph
Now that you have transformed properties in the graph to match what we want for numeric and date values in the graph, confirm that their types are correct:
CALL apoc.meta.nodeTypeProperties()
YIELD nodeType, propertyName, propertyTypes
Validate Results
Once you completed the steps of this Challenge, click the Check Database button and we will check the database for you.
Hint
To transform the lists you set three properties, countries, languages, and genres. You set them with one SET clause and each property being set is separated by a comma. You use split/coalesce to set each property.
Solution
Here is the code to transform the three properties to lists:
MATCH (m:Movie)
SET m.countries = split(coalesce(m.countries,""), "|"),
m.languages = split(coalesce(m.languages,""), "|"),
m.genres = split(coalesce(m.genres,""), "|")
If your graph does not verify, you may need to:
-
Clear the graph with:
MATCH (u:User) DETACH DELETE u;
MATCH (p:Person) DETACH DELETE p;
MATCH (m:Movie) DETACH DELETE m;
MATCH (n) DETACH DELETE n
-
Re-import the data once again with the Data Importer
-
Transform the genres, countries, languages properties to lists
Summary
In this challenge, you transformed the multi-value string data to list (StringArray) types to match our target data model. In the next lesson, you learn how to refactor the graph to add labels.