Harry Potter
Full Recipe¶
Shared by: Alec Theriault
Ingest a small JSON object to manifest a graph of connected nodes that explore the familial relationships of Harry Potter characters.
Harry Potter Recipe
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
Scenario¶
If you are new to Quine, let's start simple. This small graph of connected nodes allows you to explore the familial relationships of Harry Potter characters in Quine. Use this recipe to follow along with the examples outlined in the Exploration UI getting started guide.
Sample Data¶
Note
Download the sample data to the same directory where Quine will be run.
Before running this Recipe, download the dataset.
curl https://quine.io/recipes/images/harry_potter_data.json -o harry_potter_data.json
How it Works¶
This recipe connects an ingest stream to the harry_potter_data.json
file, parses the JSON object, manifests parent (p
) and child (c
) nodes, and creates a relationship between the nodes.
The sample data JSON object is straightforward containing character name
, gender
, birth_year
, and a list of children
.
{ "name": "James Sirius Potter", "gender": "male", "birth_year": 2003, "children": [] }
{ "name": "Albus Severus Potter", "gender": "male", "birth_year": 2005, "children": [] }
{ "name": "Lily Luna", "gender": "female", "birth_year": 2007, "children": [] }
{ "name": "Rose Weasley", "gender": "female", "birth_year": 2005, "children": [] }
{ "name": "Hugo Weasley", "gender": "male", "birth_year": 2008, "children": [] }
{ "name": "Lily Potter", "gender": "female", "birth_year": 1960, "children": ["Harry Potter"] }
{ "name": "James Potter", "gender": "male", "birth_year": 1960, "children": ["Harry Potter"] }
{ "name": "Molly Weasley", "gender": "female", "birth_year": 1949, "children": ["Ginny Weasley", "Ron Weasley"] }
{ "name": "Arthur Weasley", "gender": "male", "birth_year": 1950, "children": ["Ginny Weasley", "Ron Weasley"] }
{ "name": "Harry Potter", "gender": "male", "birth_year": 1980, "children": ["James Sirius Potter", "Albus Severus Potter", "Lily Luna"] }
{ "name": "Ginny Weasley", "gender": "female", "birth_year": 1981, "children": ["James Sirius Potter", "Albus Severus Potter", "Lily Luna"] }
{ "name": "Ron Weasley", "gender": "male", "birth_year": 1980, "children": ["Rose Weasley", "Hugo Weasley"] }
{ "name": "Hermione Granger", "gender": "female", "birth_year": 1979, "children": ["Rose Weasley", "Hugo Weasley"] }
INGEST-1 processes the harry_potter_data.json
file:
- type: FileIngest
path: harry_potter_data.json
format:
type: CypherJson
query: |-
MATCH (p) WHERE id(p) = idFrom('name', $that.name)
SET p = { name: $that.name, gender: $that.gender, birth_year: $that.birth_year },
p: Person
WITH $that.children AS childrenNames, p
UNWIND childrenNames AS childName
MATCH (c) WHERE id(c) = idFrom('name', childName)
CREATE (c)-[:has_parent]->(p)
[
{
"type": "FileIngest",
"path": "harry_potter_data.json",
"format": {
"type": "CypherJson",
"query": "MATCH (p) WHERE id(p) = idFrom('name', $that.name)\nSET p = { name: $that.name, gender: $that.gender, birth_year: $that.birth_year },\n p: Person\nWITH $that.children AS childrenNames, p\nUNWIND childrenNames AS childName\nMATCH (c) WHERE id(c) = idFrom('name', childName)\nCREATE (c)-[:has_parent]->(p)"
}
}
]
Running the Recipe¶
❯ java -jar quine-1.8.1.jar -r hpotter.yaml
Graph is ready
Running Recipe: Harry Potter
Using 2 quick queries
Running Ingest Stream INGEST-1
Quine web server available at http://localhost:8080
INGEST-1 status is completed and ingested 13
Summary¶
Open your browser and navigate to http://localhost:8080
. Click the query bar and select CALL recentNodes(10)
. Change 10
to 20
to ensure that you pick up the entire graph, and click the Query
button.
A jumbled graph will appear in your browser, click the "tree view" button () to structure the graph before you begin exploring.
Explore the graph using the pre loaded quick queries or write Cypher queries in the query bar.
Tip
Quick Queries are available by right clicking on a node.
Quick Query | Node Type | Description |
---|---|---|
Adjacent Nodes | All | Display the nodes that are adjacent to this node. |
Siblings | All | Show the has sibling relationship for this node. |
Now that you have the graph loaded into Quine, head over to the Exploration UI guide to learn more about how to use Quine's interface.