Database Reference
In-Depth Information
Loading the “Current” Status
The first file contains the “current” status update made by a user. The current status refers to the most recent status
update for a specific user. I will connect them to the user by taking the userId and matching it to a User, and then by
creating a relationship type called CURRENT . First, I execute a LOAD CSV command (Listing 5-9) to ensure that the data
has the necessary properties.
Listing 5-9. Loading the Current Status to Review before Importing
LOAD CSV WITH HEADERS FROM " http://www.graphstory.com/practicalneo4j-book/code/chapter5/csv/
currentstatus.csv " AS csvLine
return csvLine.statusId, csvLine.userId, csvLine.status
limit 5
Listing 5-10 provides the LOAD CSV command that you will need to execute to load the status updates into the
graph. As an added bonus, this will also create the relationship between the User and its current Status.
Listing 5-10. Importing the CURRENT Status Updates
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM " http://www.graphstory.com/practicalneo4j-book/code/chapter5/csv/
currentstatus.csv " AS csvLine
MATCH (u1:User { userId: toInt(csvLine.userId)} )
CREATE (u1)-[:CURRENT]->(s:Status { statusId: toInt(csvLine.statusId), userId: csvLine.userId,
status: csvLine.status })
Before you run the LoaD CSV for the CurrentStatuS import, be sure to create another unique index by
running CREATE CONSTRAINT ON (s:Status) ASSERT s.statusId IS UNIQUE .
Important
Once the command is run, you can run the following command MATCH (u:User {userId:1} )-[:CURRENT]-
>(s) RETURN u,s and you should see a result like the one shown in Figure 5-3 .
Figure 5-3. Testing the results of the CURRENT status import
 
 
Search WWH ::




Custom Search