SlideShare a Scribd company logo
1 of 54
FACEBOOK GRAPH SEARCH
How to create your own graph search using
Neo4j

jDays 2013
Ole-Martin Mørk
26/11/13
FACEBOOK GRAPH SEARCH
How to create your own graph search using
Neo4j

jDays 2013
Ole-Martin Mørk
26/11/13
ABOUT ME

Ole-Martin Mørk
Scientist

Bekk Consulting AS
Oslo, Norway

twitter: olemartin
AGENDA
INTRODUCTION TO SEARCH
INTRODUCTION TO NEO4J
INTRODUCTION TO PARSING

GRAPH SEARCH
GRAF

BETRAYS

KNOWS
KNOWS

LOVES
KNOWS
NODE

PERSON
ADRESSE

BODDE

navn: Thomas
alder: 24

gate: Aker
nummer: 15
RELASJON

BODDE
fra:
til:
RELASJONSDATABASER
“PATH EXISTS” RESPONSTID
-

One database
containing 1000
persons

-

Max 50 friends

-

Detect if two random
persons are
connected via friends

Antall
personer

Responstid

Relational db
Neo4j

1.000
1.000

2000ms
2ms

Neo4j

1.000.000

2ms
Neo4j
GRAF

C

B

A

I

D

H

E
F

G
CYPHER
GRAF

C

B

A

I

D

H

E
F

G
Cypher
CYPHER

( ) --> ( )
CYPHER

a

b

(a) --> (b)
CYPHER

a

b

c

(a)-->(b)<--(c)
CYPHER

a

kjenner

b

(a) –[:kjenner]-> (b)
CYPHER SØK

START person=node:person(name=“Ole-Martin”)
START school=node:school(“name:Norw*”)
START student=node:student(“year:(3 OR 4 OR 5)”)
FACEBOOK GRAPH SEARCH WITH CYPHER

START me=node:person(name = “Ole-Martin”),

location=node:location(location=“Göteborg”),
cuisine=node:cuisine(cuisine=“Sushi”)
MATCH (me)-[:IS_FRIEND_OF]->(friend)-[:LIKES]->(restaurant)
-[:LOCATED_IN]->(location),(restaurant)-[:SERVES]->(cuisine)
RETURN restaurant
Grammar
GRAMMAR

A “language” can be formally defined as “any system of
formalized symbols, signs, etc. used for communication”

A “grammar” can be defined as a “the set of structural rules
that governs sentences, words, etc. in a natural language”
TEXT PARSING

CFG PEG
GRAMMAR

Alfred, who loved fishing, bought fish at the store
downtown

(Alfred, (who loved (fishing)), (bought
(fish (at (the store (downtown))))))
additionExp
: multiplyExp
( '+' multiplyExp
| '-' multiplyExp
)*
;
multiplyExp
: atomExp
( '*' atomExp
| '/' atomExp
)*
;

atomExp
: Number
| '(' additionExp ')'
;
Number
: ('0'..'9')+
;

An additionExp is defined as a multiplyExp
+ or - a multiplyExp

A multiplyExp is defined as an atomExp *
or / an atomExp

An atomExp is defined as a number or a
parenthesized additionExp

Number is one or more character between
0-9
class CalculatorParser extends BaseParser<> {

Rule Expression() {
return Sequence(
Term(),
ZeroOrMore(AnyOf("+-"), Term())
);
}

An expression is a sequence of Term
followed by zero or more “+” or “-” followed
by a Term

Rule Term() {
return Sequence(
Factor(),
ZeroOrMore(AnyOf("*/"), Factor())
);
}

Term is a Factor followed by zero or more
sequences of “*” or “/” followed by a factor

Rule Factor() {
return FirstOf(
Number(),
Sequence('(', Expression(), ')')
);
}

Factor is a number or a parenthesized
expression

Rule Number() {
return OneOrMore(CharRange('0', '9'));

Number is a one or more characters
between 0-9
PEG VS CFG

PEGs firstof operator vs CFG’s | operator
PEG does not have a separate tokenizing step
CFG might come across as more powerful, but also more difficult to master
PEG does not allow ambiguity in the grammar
PARBOILED
PARBOILED
Parsing expression grammars parser
Lightweight
Easy to use
Implementation in Scala and Java
Rules are written in the programming language
class CalculatorParser extends BaseParser<> {

Rule Expression() {
return Sequence(
Term(),
ZeroOrMore(AnyOf("+-"), Term())
);
}

An expression is a sequence of Term
followed by zero or more “+” or “-” followed
by a Term

Rule Term() {
return Sequence(
Factor(),
ZeroOrMore(AnyOf("*/"), Factor())
);
}

Term is a Factor followed by zero or more
sequences of “*” or “/” followed by a factor

Rule Factor() {
return FirstOf(
Number(),
Sequence('(', Expression(), ')')
);
}

Factor is a number or a parenthesized
expression

Rule Number() {
return OneOrMore(CharRange('0', '9'));

Number is a one or more characters
between 0-9
I went for a walk downtown

Sequence( “I”, “went”, “for”, “a”, “walk”, “downtown”)
went
downtown
I
for a walk
wend
to the city
Sequence(
String(“I”),

FirstOf(“went”, “wend”),
Sequence(“for”, “a”, “walk”),

FirstOf(“downtown”, “to the city”));
went
downtown
today
I
for a walk
walked
to the city
Sequence(
…,

Optional(String(“today”)));
went
downtown
today
for a walk
today I
walked
to the city
Sequence(
Today(),

…,
Today());

Rule Today() { return Optional(String(“today”)); }
Rule AnyOf(java.lang.String characters)

Creates a new rule that matches any of
the characters in the given string.
Rule Ch(char c)

Explicitly creates a rule matching the
given character.
Rule CharRange(char cLow, char cHigh)

Creates a rule matching a range of
characters from cLow to cHigh (both
inclusively).
Rule FirstOf(java.lang.Object... rules)

Creates a new rule that successively
tries all of the given subrules and succeeds
when the first one of its subrules matches.
Rule IgnoreCase(char... characters)

Explicitly creates a rule matching the
given string in a case-independent fashion.
Rule NoneOf(char... characters)

Creates a new rule that matches all
characters except the ones in the given char
array and EOI.
Rule NTimes(int repetitions,
java.lang.Object rule)

Creates a new rule that repeatedly
matches a given sub rule a certain fixed
number of times.
went
downtown
today
for a walk
today I
walked
to the city
Sequence(
…,

FirstOf(
Sequence(push(“downtown”), “downtown”,

Sequence(push(“city”), “to the city”)));
BEKK
CV-db
A search for Java

yields 224 hits!
public Rule Expression() {
return Sequence(
Start(),
FirstOf(People(), Projects(), Technologies()),
OneOrMore(
FirstOf(
And(),
Sequence(
Know(),
Subjects()
),
Sequence(
WorkedAt(),
Customers()
),
Sequence(
Know(),
Customers()
),
Sequence(
Know(),
Technologies()
)
)
)
);
}
start
fag=node:fag(navn = "Neo4J"), fag1=node:fag(navn =
"Java"), prosjekt2=node:prosjekt(navn ="Modernisering")
match
CONSULTANTS -[:KAN]-> fag,
CONSULTANTS -[:KAN]-> fag1,
CONSULTANTS -[:KONSULTERTE]-> prosjekt
return
distinct CONSULTANTS
Demo
LEARN MORE

graphdatabases.com
neo4j.org
bit.ly/neo-cyp
parboiled.org
?
Thank
you!

@olemartin

More Related Content

What's hot

Mining the social web ch1
Mining the social web ch1Mining the social web ch1
Mining the social web ch1HyeonSeok Choi
 
The Ring programming language version 1.3 book - Part 35 of 88
The Ring programming language version 1.3 book - Part 35 of 88The Ring programming language version 1.3 book - Part 35 of 88
The Ring programming language version 1.3 book - Part 35 of 88Mahmoud Samir Fayed
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?osfameron
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88Mahmoud Samir Fayed
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionosfameron
 
Cryptography for Smalltalkers 2
Cryptography for Smalltalkers 2Cryptography for Smalltalkers 2
Cryptography for Smalltalkers 2ESUG
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 23 of 196
The Ring programming language version 1.7 book - Part 23 of 196The Ring programming language version 1.7 book - Part 23 of 196
The Ring programming language version 1.7 book - Part 23 of 196Mahmoud Samir Fayed
 
Frsa
FrsaFrsa
Frsa_111
 
The Ring programming language version 1.5.4 book - Part 45 of 185
The Ring programming language version 1.5.4 book - Part 45 of 185The Ring programming language version 1.5.4 book - Part 45 of 185
The Ring programming language version 1.5.4 book - Part 45 of 185Mahmoud Samir Fayed
 

What's hot (15)

Mining the social web ch1
Mining the social web ch1Mining the social web ch1
Mining the social web ch1
 
The Ring programming language version 1.3 book - Part 35 of 88
The Ring programming language version 1.3 book - Part 35 of 88The Ring programming language version 1.3 book - Part 35 of 88
The Ring programming language version 1.3 book - Part 35 of 88
 
CSS for developers
CSS for developersCSS for developers
CSS for developers
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212
 
The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures edition
 
Cryptography for Smalltalkers 2
Cryptography for Smalltalkers 2Cryptography for Smalltalkers 2
Cryptography for Smalltalkers 2
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180
 
Be Lazy & Scale
Be Lazy & ScaleBe Lazy & Scale
Be Lazy & Scale
 
Fs2 - Crash Course
Fs2 - Crash CourseFs2 - Crash Course
Fs2 - Crash Course
 
The Ring programming language version 1.7 book - Part 23 of 196
The Ring programming language version 1.7 book - Part 23 of 196The Ring programming language version 1.7 book - Part 23 of 196
The Ring programming language version 1.7 book - Part 23 of 196
 
Opa hackathon
Opa hackathonOpa hackathon
Opa hackathon
 
Frsa
FrsaFrsa
Frsa
 
The Ring programming language version 1.5.4 book - Part 45 of 185
The Ring programming language version 1.5.4 book - Part 45 of 185The Ring programming language version 1.5.4 book - Part 45 of 185
The Ring programming language version 1.5.4 book - Part 45 of 185
 

Viewers also liked

Agile Development + Interaction design = True
Agile Development + Interaction design = TrueAgile Development + Interaction design = True
Agile Development + Interaction design = TrueKlara Vatn
 
Digital Meets Physical: Collective Currents, et IoT-eksperiment
Digital Meets Physical: Collective Currents, et IoT-eksperimentDigital Meets Physical: Collective Currents, et IoT-eksperiment
Digital Meets Physical: Collective Currents, et IoT-eksperimentLillian Ayla Ersoy
 
First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...Rosenfeld Media
 
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...Sonatype
 

Viewers also liked (6)

Agile Development + Interaction design = True
Agile Development + Interaction design = TrueAgile Development + Interaction design = True
Agile Development + Interaction design = True
 
Digital Meets Physical: Collective Currents, et IoT-eksperiment
Digital Meets Physical: Collective Currents, et IoT-eksperimentDigital Meets Physical: Collective Currents, et IoT-eksperiment
Digital Meets Physical: Collective Currents, et IoT-eksperiment
 
Polyglot heaven
Polyglot heavenPolyglot heaven
Polyglot heaven
 
First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...
 
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
 
Design Thinking and Lean UX
Design Thinking and Lean UXDesign Thinking and Lean UX
Design Thinking and Lean UX
 

Similar to Graph search with Neo4j

FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfFUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfBryan Alejos
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better JavaThomas Kaiser
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful weddingStéphane Wirtel
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...adrianoalmeida7
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212Mahmoud Samir Fayed
 
Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"LogeekNightUkraine
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)William Narmontas
 
Arrays string handling java packages
Arrays string handling java packagesArrays string handling java packages
Arrays string handling java packagesSardar Alam
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to PerlSway Wang
 
How to write code you won't hate tomorrow
How to write code you won't hate tomorrowHow to write code you won't hate tomorrow
How to write code you won't hate tomorrowPete McFarlane
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's JavaSven Efftinge
 

Similar to Graph search with Neo4j (20)

FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfFUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful wedding
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
String slide
String slideString slide
String slide
 
A bit about Scala
A bit about ScalaA bit about Scala
A bit about Scala
 
Strings and Characters
Strings and CharactersStrings and Characters
Strings and Characters
 
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"
 
Scala
ScalaScala
Scala
 
Intro toswift1
Intro toswift1Intro toswift1
Intro toswift1
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)
 
Arrays string handling java packages
Arrays string handling java packagesArrays string handling java packages
Arrays string handling java packages
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
How to write code you won't hate tomorrow
How to write code you won't hate tomorrowHow to write code you won't hate tomorrow
How to write code you won't hate tomorrow
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's Java
 

More from Ole-Martin Mørk

More from Ole-Martin Mørk (9)

Polyglot Persistence
Polyglot PersistencePolyglot Persistence
Polyglot Persistence
 
Patterns for key-value stores
Patterns for key-value storesPatterns for key-value stores
Patterns for key-value stores
 
Presentation of Redis
Presentation of RedisPresentation of Redis
Presentation of Redis
 
Evolusjonen av PaaS
Evolusjonen av PaaSEvolusjonen av PaaS
Evolusjonen av PaaS
 
Polyglot persistence
Polyglot persistencePolyglot persistence
Polyglot persistence
 
Du må vite hva som skjer i produksjon
Du må vite hva som skjer i produksjonDu må vite hva som skjer i produksjon
Du må vite hva som skjer i produksjon
 
Presentasjon om skyen
Presentasjon om skyenPresentasjon om skyen
Presentasjon om skyen
 
Hele butikken i skyen
Hele butikken i skyenHele butikken i skyen
Hele butikken i skyen
 
Collaborative Filtering in Map/Reduce
Collaborative Filtering in Map/ReduceCollaborative Filtering in Map/Reduce
Collaborative Filtering in Map/Reduce
 

Recently uploaded

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 

Recently uploaded (20)

Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 

Graph search with Neo4j

  • 1. FACEBOOK GRAPH SEARCH How to create your own graph search using Neo4j jDays 2013 Ole-Martin Mørk 26/11/13
  • 2.
  • 3. FACEBOOK GRAPH SEARCH How to create your own graph search using Neo4j jDays 2013 Ole-Martin Mørk 26/11/13
  • 4. ABOUT ME Ole-Martin Mørk Scientist Bekk Consulting AS Oslo, Norway twitter: olemartin
  • 5. AGENDA INTRODUCTION TO SEARCH INTRODUCTION TO NEO4J INTRODUCTION TO PARSING GRAPH SEARCH
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 16.
  • 18. “PATH EXISTS” RESPONSTID - One database containing 1000 persons - Max 50 friends - Detect if two random persons are connected via friends Antall personer Responstid Relational db Neo4j 1.000 1.000 2000ms 2ms Neo4j 1.000.000 2ms
  • 19. Neo4j
  • 28. CYPHER SØK START person=node:person(name=“Ole-Martin”) START school=node:school(“name:Norw*”) START student=node:student(“year:(3 OR 4 OR 5)”)
  • 29. FACEBOOK GRAPH SEARCH WITH CYPHER START me=node:person(name = “Ole-Martin”), location=node:location(location=“Göteborg”), cuisine=node:cuisine(cuisine=“Sushi”) MATCH (me)-[:IS_FRIEND_OF]->(friend)-[:LIKES]->(restaurant) -[:LOCATED_IN]->(location),(restaurant)-[:SERVES]->(cuisine) RETURN restaurant
  • 31. GRAMMAR A “language” can be formally defined as “any system of formalized symbols, signs, etc. used for communication” A “grammar” can be defined as a “the set of structural rules that governs sentences, words, etc. in a natural language”
  • 33. GRAMMAR Alfred, who loved fishing, bought fish at the store downtown (Alfred, (who loved (fishing)), (bought (fish (at (the store (downtown))))))
  • 34. additionExp : multiplyExp ( '+' multiplyExp | '-' multiplyExp )* ; multiplyExp : atomExp ( '*' atomExp | '/' atomExp )* ; atomExp : Number | '(' additionExp ')' ; Number : ('0'..'9')+ ; An additionExp is defined as a multiplyExp + or - a multiplyExp A multiplyExp is defined as an atomExp * or / an atomExp An atomExp is defined as a number or a parenthesized additionExp Number is one or more character between 0-9
  • 35. class CalculatorParser extends BaseParser<> { Rule Expression() { return Sequence( Term(), ZeroOrMore(AnyOf("+-"), Term()) ); } An expression is a sequence of Term followed by zero or more “+” or “-” followed by a Term Rule Term() { return Sequence( Factor(), ZeroOrMore(AnyOf("*/"), Factor()) ); } Term is a Factor followed by zero or more sequences of “*” or “/” followed by a factor Rule Factor() { return FirstOf( Number(), Sequence('(', Expression(), ')') ); } Factor is a number or a parenthesized expression Rule Number() { return OneOrMore(CharRange('0', '9')); Number is a one or more characters between 0-9
  • 36. PEG VS CFG PEGs firstof operator vs CFG’s | operator PEG does not have a separate tokenizing step CFG might come across as more powerful, but also more difficult to master PEG does not allow ambiguity in the grammar
  • 38. PARBOILED Parsing expression grammars parser Lightweight Easy to use Implementation in Scala and Java Rules are written in the programming language
  • 39. class CalculatorParser extends BaseParser<> { Rule Expression() { return Sequence( Term(), ZeroOrMore(AnyOf("+-"), Term()) ); } An expression is a sequence of Term followed by zero or more “+” or “-” followed by a Term Rule Term() { return Sequence( Factor(), ZeroOrMore(AnyOf("*/"), Factor()) ); } Term is a Factor followed by zero or more sequences of “*” or “/” followed by a factor Rule Factor() { return FirstOf( Number(), Sequence('(', Expression(), ')') ); } Factor is a number or a parenthesized expression Rule Number() { return OneOrMore(CharRange('0', '9')); Number is a one or more characters between 0-9
  • 40. I went for a walk downtown Sequence( “I”, “went”, “for”, “a”, “walk”, “downtown”)
  • 41. went downtown I for a walk wend to the city Sequence( String(“I”), FirstOf(“went”, “wend”), Sequence(“for”, “a”, “walk”), FirstOf(“downtown”, “to the city”));
  • 42. went downtown today I for a walk walked to the city Sequence( …, Optional(String(“today”)));
  • 43. went downtown today for a walk today I walked to the city Sequence( Today(), …, Today()); Rule Today() { return Optional(String(“today”)); }
  • 44. Rule AnyOf(java.lang.String characters) Creates a new rule that matches any of the characters in the given string. Rule Ch(char c) Explicitly creates a rule matching the given character. Rule CharRange(char cLow, char cHigh) Creates a rule matching a range of characters from cLow to cHigh (both inclusively). Rule FirstOf(java.lang.Object... rules) Creates a new rule that successively tries all of the given subrules and succeeds when the first one of its subrules matches. Rule IgnoreCase(char... characters) Explicitly creates a rule matching the given string in a case-independent fashion. Rule NoneOf(char... characters) Creates a new rule that matches all characters except the ones in the given char array and EOI. Rule NTimes(int repetitions, java.lang.Object rule) Creates a new rule that repeatedly matches a given sub rule a certain fixed number of times.
  • 45. went downtown today for a walk today I walked to the city Sequence( …, FirstOf( Sequence(push(“downtown”), “downtown”, Sequence(push(“city”), “to the city”)));
  • 47. A search for Java yields 224 hits!
  • 48.
  • 49. public Rule Expression() { return Sequence( Start(), FirstOf(People(), Projects(), Technologies()), OneOrMore( FirstOf( And(), Sequence( Know(), Subjects() ), Sequence( WorkedAt(), Customers() ), Sequence( Know(), Customers() ), Sequence( Know(), Technologies() ) ) ) ); }
  • 50. start fag=node:fag(navn = "Neo4J"), fag1=node:fag(navn = "Java"), prosjekt2=node:prosjekt(navn ="Modernisering") match CONSULTANTS -[:KAN]-> fag, CONSULTANTS -[:KAN]-> fag1, CONSULTANTS -[:KONSULTERTE]-> prosjekt return distinct CONSULTANTS
  • 51. Demo
  • 53. ?

Editor's Notes

  1. Ole-Martin MørkScientist hos BEKK
  2. Jeger Scientist i Bekk hvorjegharjobbetmerellermindresiden 2000.Jeger @olemartinpå twitter, oghvisnoenhar et spørsmålellertilbakemelding under fordragetså ta detgjerne der.
  3. EvolusjonFormel 1Verdensarterogsøkogsøkemotorerså kun påenkeltdokumentermanuellkategorisering
  4. pagerankfragooglealle sider får en pagerankbasertpåinnholdetpåsidenogpagerankpåsidenesomlenker inn
  5. Googles Knowledge Graph, where you can follow relations between different knowledge. Search for Mona Lisa
  6. and you get dynamic information about that picture displayed in the sidebar
  7. Mark Zuckerbergmed facebook graph search vistefacebook at relasjonenevar like viktigsomdataeneomjeg liker fotografi, ogborioslokunneværtioslo, ellerværtfødtioslo, men jeg BOR iosloogdet her visersegåværeveldigkraftig
  8. Facebook Graph Search developed by Lars Rasmussen, the danish dude that created Google Wave.They use a Context Free Grammar, which is translated to a query they run against an index called Unicorn that has a graph-like architecture.
  9. You can also search for combined queries, like people from gothenburg that works as a barista in Oslo, lots of those around :-)
  10. Dettehaddeikkeværtmuliguten en graf-strukturibunnen.Ogdetteer en graf:En grafbestårenkeltforklartavnoderogrelasjoner.En relasjongårfra en node til en annen node. Skalrelasjonengåbeggeveier, må du ha to.Noderkan ha attrubutterogrelasjonerkan ha attributter
  11. Somnavnog alderosvHvis du har data somandrenoderkantenkesegårelateretil, såskiller du den ut via en relasjon
  12. Ogrelasjonenharogsåattributter
  13. If we go back to the monalisa example, some of the attributes presented are in fact attributes, others actually relationships
  14. Fordet vi såkanogsåløses med en relasjonsdatabase.MENStatiskeskjemaer, definereshvordandataeneserutførstTungtåjobbe med mange ogdyperelasjonerogikkeminstytelse
  15. Created in Sweden! :-) By Emil EifremNow have offices in sweden, malaysia with Rickard Øberg, uk with Jim Webber, united states etc. A fast growing company, making some really nice technology. And nobody is paying me a dime to say this, I just love their technology.17 minutter hit
  16. Vi gårtilbaketilgrafen
  17. Det her erogså en grafforsåvidt, dvs en veldiglitengraf.En node med en relasjontil en annen node.
  18. Hvis vi tar detuttrykketogsøkeretterdetidatabasensåfinner man det.Man vilforsåvidtfinneallestederhvor en node errelaterttil en annen
  19. I Matrix erhanikke et godtselskap for Neo, men i Neo4j såer de perlevenner
  20. Ogdetsomerfantastisker at detteer en gyldigi Neo4j
  21. Navngittenoder
  22. Flerenavngittenoder
  23. Relasjonerav en viss type
  24. So… Now we have the database and query language. Now we only need to define some grammar.
  25. A language, norsk,ellerskavlan-svenska, or english
  26. CFG - context free grammar, used byfacebook graph search and many many programming languages. Been used for defining programming languages since the 50sparsing expression grammar, the new kid on the block, defined in 2004
  27. May look a little like LISP
  28. Parboiled is written by a german named Mathias Doenitz. This man has managed to create a user friendly and powerful PEG-parser. Mathias has also created spray.io, a really powerful akka-based REST-module for Scala.Parboiled is the main reason why I went with PEG in my project. Parboiled is easy to understand, and has all the features necessery for
  29. 34 minutter hit
  30. whitespaces
  31. ValueStack
  32. ValueStack
  33. Inside your rulesyou might add values to the ValueStack.This is a great way for your rules and actions to communicate, or you can use this to return values from the parsing process.
  34. Vi brukervår cv-databasenaktivt. Når en kundeetterspør en konsulentsomkan neo4j såsøkerselgerengjennomdatabasen. Hviskundenharkravomrelasjoner, andrefagfeltetcsåblirdetkomplekst med fritekst-søk.
  35. Our search is currently a free text search, and a search for Java gives 224 hits. We have 200 developers in our company, including lots of .net developers.
  36. Så la oss sepå en demo
  37. Twitter