Database Reference
In-Depth Information
Loading the “NEXT” Status
As the last step for loading status updates, you can import the final set and associate them through a LOAD CSV
using the NEXT relationship type for each one, shown in Listings 5-11 and 5-12. You can use the statusId as a key
because it is unique.
Listing 5-11. First Set of “NEXT” Status Updates with LOAD CSV
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "http://www.graphstory.com/practicalneo4j-book/code/chapter5/
csv/ nextstatus1.csv " AS csvLine
MATCH (s1:Status { statusId: toInt(csvLine. lastStatusId )} )
CREATE (s1)-[: NEXT ]->(s:Status { statusId: toInt(csvLine.statusId), userId: csvLine.userId, status:
csvLine.status })
Listing 5-12. Second Set of “NEXT” Status Updates with LOAD CSV
USING PERIODIC COMMIT
LOAD CSV WITH HEADERS FROM "http://www.graphstory.com/practicalneo4j-book/code/chapter5/
csv/nextstatus2.csv" AS csvLine
MATCH (s1:Status { statusId: toInt(csvLine. nextToLastStatusId )} )
CREATE (s1)-[: NEXT ]->(s:Status { statusId: toInt(csvLine.statusId), userId: csvLine.userId, status:
csvLine.status })
Once the first “NEXT” status command is run, you can run the command MATCH (u:User {userId:1} )-
[:CURRENT]->(s) -[:NEXT]-(n) return u,s,n and you should see a result like the one shown in
Figure 5-4 . Finally, run the second “NEXT” status command and then run the command MATCH (u:User {userId:1}
)-[:CURRENT]->(s)-[:NEXT*0..2]-(n) return u,s,n and you should see a result like the one shown in Figure 5-5 .
Figure 5-4. Displaying the user, current status, and next status
 
Search WWH ::




Custom Search