Top Banner
Building a recommendation engine with TinkerPop Otávio Santana @otaviojava [email protected] [email protected]
32

Building a recommendation engine with tinker pop

Jan 28, 2018

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building a recommendation engine with tinker pop

Building a recommendation engine with TinkerPop

Otávio Santana@[email protected]@apache.org

Page 2: Building a recommendation engine with tinker pop

NoSQL● Database● Doesn't use structure● Not Transaction● BASE● Types

Page 3: Building a recommendation engine with tinker pop

Graph

● Neo4j● InfoGrid● Sones● HyperGraphDB

Apollo Ares

Kratoswas killed by was killed by

Is brother

killed killed

Page 4: Building a recommendation engine with tinker pop

SQL Key-value Document Column Graph

Table Bucket Collection Column Family

Vertex and Edge

Row Key/value pair

Document Column Vertex

Column Key/value pair

Key/value pair

Vertex and Edge property

Relationship Link Edge

Page 5: Building a recommendation engine with tinker pop

Scalability vs Complexity

Scalability

Complexity

Page 6: Building a recommendation engine with tinker pop

Scalability vs Complexity

Scalability

Complexity

key-value

Column

Document

Graph

Page 7: Building a recommendation engine with tinker pop

Graph

Grace Hopper

label Person

id ada

name Ada Lovelace

occupation scientist

Ada Lovelace

label Person

id grace

name Grace Hopper

occupation scientist

Knows

Vertex Vertex

Edge

Page 8: Building a recommendation engine with tinker pop

Graph

Radioactive

label Person

id marie_curie

name Marie Curie

occupation scientist

Marie Curie

label nature

id radioactive

name Radioactive

discovers

when 1867

where Europe

Page 9: Building a recommendation engine with tinker pop

Graph Database

Page 10: Building a recommendation engine with tinker pop

TinkerPop

Page 11: Building a recommendation engine with tinker pop

TinkerPop

Grace Hopper

label Person

id grace

name Grace Hopper

occupation scientist

Vertex

grace = graph.addVertex( T.label, "person", "id", "grace", "name", "Grace Hopper", "occupation", "scientist");

Page 12: Building a recommendation engine with tinker pop

TinkerPop

Grace Hopper

Ada Lovelace

Knows

grace.addEdge("knows", ada);

Page 13: Building a recommendation engine with tinker pop

Edges

Out ->

In <-

Both

Page 14: Building a recommendation engine with tinker pop

Marketing Campaign● Engineer● Salary 3000● Age between 20 and 25 years ● Man

Page 15: Building a recommendation engine with tinker pop

SQLId name Occupation Salary age gender

... ... ... ... ... ...

SELECT * FROM Person WHERE

occupation = "Engineer" AND

salary > 3000 and age BETWEEN 20

AND 25

Page 16: Building a recommendation engine with tinker pop

TinkerPopGrace Hopper

Ada Lovelace

Knows

g.V().has("occupation","Engineer").has("salary", gt(3000)).has("age", between(20, 25));

Page 17: Building a recommendation engine with tinker pop

SQLId name Occupation Salary age gender

... ... ... ... ... ...

SELECT name FROM Person WHERE

occupation = "Engineer" AND

salary > 3000 and age BETWEEN 20

AND 25

Page 18: Building a recommendation engine with tinker pop

TinkerPopGrace Hopper

Ada Lovelace

Knows

g.V().has("occupation","Engineer").has("salary", gt(3000)).has("age", between(20, 25)).values("name");

Page 19: Building a recommendation engine with tinker pop

SQLId name Occupation Salary age gender

... ... ... ... ... ...

SELECT count(*) FROM Person WHERE

occupation = "Engineer" AND

salary > 3000 and age BETWEEN 20

AND 25

Page 20: Building a recommendation engine with tinker pop

TinkerPopGrace Hopper

Ada Lovelace

Knows

g.V().has("occupation","Engineer").has("salary", gt(3000)).has("age", between(20, 25)).count();

Page 21: Building a recommendation engine with tinker pop

TinkerPopGrace Hopper

Ada Lovelace

Knows

g.V().has("occupation","Engineer").has("salary", gt(3000)).has("age", between(20, 25)).groupCount().by(“city”);

Page 22: Building a recommendation engine with tinker pop

Their Friends

Page 23: Building a recommendation engine with tinker pop

SQLId name Occupation Salary age gender

... ... ... ... ... ...

SELECT * FROM Person WHERE

occupation = "Engineer" AND

salary > 3000 and age BETWEEN 20

AND 25//...joins

Id know

... ...

Page 24: Building a recommendation engine with tinker pop

TinkerPopGrace Hopper

Ada Lovelace

Knows

g.V().has("occupation","Engineer").has("salary", gt(3000)).has("age", between(20, 25)).out("knows");

Page 25: Building a recommendation engine with tinker pop

Falling in love

Page 26: Building a recommendation engine with tinker pop

SQLId name Occupation Salary age gender

... ... ... ... ... ...

SELECT * FROM Person WHERE

occupation = "Engineer" AND

salary > 3000 and age BETWEEN 20

AND 25//...joins

Id know

... ...

Id love

... ...

Page 27: Building a recommendation engine with tinker pop

TinkerPopGrace Hopper

Ada Lovelace

Knows

g.V().has("occupation","Engineer").has("salary", gt(3000)).has("age", between(20, 25)).outE("knows").has("feel", "love").bothV();

Page 28: Building a recommendation engine with tinker pop

g.V().repeat(out("eats")).times(3);

g.V().repeat(out("eats")).until(has("name", "grass"));

//path().by("name");

Page 29: Building a recommendation engine with tinker pop
Page 30: Building a recommendation engine with tinker pop

TinkerPop

Page 31: Building a recommendation engine with tinker pop

Our database is too slow and not big enough!

We need NoSql!

Page 32: Building a recommendation engine with tinker pop

Thank You

Otávio Santana@[email protected]@apache.org