Creating a Neo4j Graph Database (and more) based on Game of Thrones (A Song of Ice and Fire) data.
Westeros data can be retrieved from An API of Ice And Fire by Joakim Skoog.
The repository contains the original JSON files, so we can use them directly.
- https://raw.githubusercontent.com/joakimskoog/AnApiOfIceAndFire/master/data/houses.json
- https://raw.githubusercontent.com/joakimskoog/AnApiOfIceAndFire/master/data/characters.json
- Person (name, titles, houses, ...)
- House (name, allies, follows, followers, founder, words, ...)
- Seat (name)
- Region (name)
Spin up a Neo4j Sandbox with the data and push our schema file.
npm install -g neo4j-graphql-cli
neo4j-graphql got-schema.graphql
Either run the content of the import scripts got-import.cypher
in Neo4j Browser or via cypher-shell
# one of these
apt-get install cypher-shell
brew install cypher-shell
# and then
cypher-shell -a bolt://<sandbox-ip>:<bolt-port> -u neo4j -p <password> < got-import.cypher
# or using Docker
docker run -ti -p `pwd`:/import neo4j /bin/sh -c '/var/lib/neo4j/bin/cypher-shell -a bolt://<sandbox-ip>:<bolt-port> -u neo4j -p <password> < /import/got-import.cypher'
Via GraphiQL, instructions below copied from Neo4j Sandbox:
-
Your GraphQL endpoint is available at
https://<10-0-1-...-.....>.neo4jsandbox.com/graphql/
. We use HTTP Basic Auth, so be sure to set an auth header:Authorization: Basic xYXcXCCXCXCXCXCXCXCXCXCX=
-
Explore your GraphQL API with our hosted
GraphiQL IDE
.
Example GraphQL Query
{
House(name: "House Stark of Winterfell") {
name
words
founder {
name
}
seats {
name
}
region {
name
}
follows {
name
}
followers(first:10) {
name
seats { name }
}
}
}
- Visit the
Neo4j Browser
. You'll automatically be authenticated.
Example Cypher queries:
MATCH path = (p:Person {name:"Steffon Baratheon"})-[:PARENT_OF*]->()
RETURN path
- Network of Thrones by Andrew Beveridge, Character interactions
- William Lyon Import and Analytics of the above into Neo4j
:play https://guides.neo4j.com/got
- Wikia Data via Mark Needham Repository:
:play https://guides.neo4j.com/got_wwc
- Tomaz Bratanic Battles from Kaggle data
- Chris Willemsen, NLP Analytics on GoT Books