Professional Documents
Culture Documents
Modeling A Recommendation Engine Workshop
Modeling A Recommendation Engine Workshop
Modeling A Recommendation Engine Workshop
Logistics
Wi-fi
network: CodeNode
password: welovecode
Join: meetup.com/graphdb-london
Join neo4j.com/slack #london-reco-201609
meetup.coms recommendations
Recommendation queries
Several different types
groups to join
topics to follow
events to attend
The data
meetup.com/meetup_api/
Groups
Members
Events
Topics
Time & Date
Location
Follow Along
Run the first guide with us
Take Note
Indexes and Constraints
Unique constraints
We create unique constraints to:
ensure uniqueness
allow fast lookup of nodes which match
these label/property pairs.
Unique constraints
We create unique constraints to:
ensure uniqueness
allow fast lookup of nodes which match
these label/property pairs.
CREATE CONSTRAINT ON (t:Topic)
ASSERT t.id IS UNIQUE
Indexes
We create indexes to:
allow fast lookup of nodes which match
these label/property pairs.
Indexes
We create indexes to:
allow fast lookup of nodes which match
these label/property pairs.
CREATE INDEX ON :Group(name)
Indexes
The following are index backed:
Equality
STARTS WITH
CONTAINS,
ENDS WITH
Range searches
(Non-)existence checks
Continue
Continue with the Guide
Exercise
Explore the Graph
Solution
Explore the Graph
Continue
Continue with the Guide
Next Step
Group Membership
Group memberships
Next Guide
Group Membership
Watch Out
Transactions & WITH
Periodic Commit
Cypher keeps all transaction state in memory
while running a query which is fine most of the
time.
Periodic Commit
Cypher keeps all transaction state in memory
while running a query which is fine most of the
time.
But when using LOAD CSV, this state can get
very large and may result in an OutOfMemory
exception.
Periodic Commit
// defaults to 1000
USING PERIODIC COMMIT
LOAD CSV
...
Periodic Commit
// defaults to 1000
USING PERIODIC COMMIT 10000
LOAD CSV
...
WITH
The WITH clause allows query parts to be chained
together, piping the results from one to be used
as starting points or criteria in the next.
WITH
Its used to:
limit the number of entries that are then
passed on to other MATCH clauses.
filter on aggregated values
separate reading from updating of the graph
Continue
Continue with the Guide
Exercise
Find yourself and your groups
Solution
Find yourself and your groups
Continue
Continue with the Guide
Next Step
Member Interest
Member interests
Attention
Lists with split & UNWIND
Continue
Continue with the Guide
Exercise
My inferred interests
Solution
My inferred interests
My inferred interests
Type the following command into the Neo4j
browser to see the answers:
:play http://guides.neo4j.com/reco/answers/3.html
Continue
Continue with the Guide
Next Guide
Events
Exercise
Event recommendations
Solution
Event recommendations
Event recommendations
Type the following command into the Neo4j
browser to see the answers:
:play http://guides.neo4j.com/reco/4.html
Continue
Continue with the Guide
Next Guide
Venues
Exercise
Import venues
Solution
Import venues
Import venues
Type the following command into the Neo4j
browser to see the answers:
:play http://guides.neo4j.com/reco/5a.html
Continue
Continue with the Guide
Next Step
Calculating Distances
Calculating distances
The distance function lets us find the
distance in metres between two points
Calculating distances
The distance function lets us find the
distance in metres between two points
Points can be maps or nodes which contain the
properties 'latitude' and 'longitude'.
RETURN distance(point1, point2)
Continue
Continue with the Guide
Exercise
Using venues in recommendation
Solution
Using venues in recommendation
Next Guide
RSVPs
Exercise
Events at my venues
Solution
Events at my venues
Events at my venues
Type the following command into the Neo4j
browser to see the answers:
:play http://guides.neo4j.com/reco/6.html
Next Guide
Procedures
Exercise
Import photos metadata
Solution
Import photos metadata
Next Guide
Latent Social Graph
Watch Out
Transaction State
Transaction State
Cypher keeps all transaction state in memory
while running a query which is fine most of the
time.
But when refactoring the graph, this state can
get very large and may result in an
OutOfMemory exception.
Continue
Continue with the Guide
Exercise
Add friends to recommendation
Solution
Add friends to recommendation
Next Guide
Scoring
Next Guide
Your turn