Your SlideShare is downloading. ×
0
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Graph search with Neo4j
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Graph search with Neo4j

970

Published on

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
970
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Ole-Martin MørkScientist hos BEKK
  • Jeger Scientist i Bekk hvorjegharjobbetmerellermindresiden 2000.Jeger @olemartinpå twitter, oghvisnoenhar et spørsmålellertilbakemelding under fordragetså ta detgjerne der.
  • EvolusjonFormel 1Verdensarterogsøkogsøkemotorerså kun påenkeltdokumentermanuellkategorisering
  • pagerankfragooglealle sider får en pagerankbasertpåinnholdetpåsidenogpagerankpåsidenesomlenker inn
  • Googles Knowledge Graph, where you can follow relations between different knowledge. Search for Mona Lisa
  • and you get dynamic information about that picture displayed in the sidebar
  • 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
  • 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.
  • You can also search for combined queries, like people from gothenburg that works as a barista in Oslo, lots of those around :-)
  • 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
  • Somnavnog alderosvHvis du har data somandrenoderkantenkesegårelateretil, såskiller du den ut via en relasjon
  • Ogrelasjonenharogsåattributter
  • If we go back to the monalisa example, some of the attributes presented are in fact attributes, others actually relationships
  • Fordet vi såkanogsåløses med en relasjonsdatabase.MENStatiskeskjemaer, definereshvordandataeneserutførstTungtåjobbe med mange ogdyperelasjonerogikkeminstytelse
  • 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
  • Vi gårtilbaketilgrafen
  • Det her erogså en grafforsåvidt, dvs en veldiglitengraf.En node med en relasjontil en annen node.
  • Hvis vi tar detuttrykketogsøkeretterdetidatabasensåfinner man det.Man vilforsåvidtfinneallestederhvor en node errelaterttil en annen
  • I Matrix erhanikke et godtselskap for Neo, men i Neo4j såer de perlevenner
  • Ogdetsomerfantastisker at detteer en gyldigi Neo4j
  • Navngittenoder
  • Flerenavngittenoder
  • Relasjonerav en viss type
  • So… Now we have the database and query language. Now we only need to define some grammar.
  • A language, norsk,ellerskavlan-svenska, or english
  • 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
  • May look a little like LISP
  • 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
  • 34 minutter hit
  • whitespaces
  • ValueStack
  • ValueStack
  • 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.
  • Vi brukervår cv-databasenaktivt. Når en kundeetterspør en konsulentsomkan neo4j såsøkerselgerengjennomdatabasen. Hviskundenharkravomrelasjoner, andrefagfeltetcsåblirdetkomplekst med fritekst-søk.
  • 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.
  • Så la oss sepå en demo
  • Twitter
  • Transcript

    • 1. FACEBOOK GRAPH SEARCH How to create your own graph search using Neo4j jDays 2013 Ole-Martin Mørk 26/11/13
    • 2. FACEBOOK GRAPH SEARCH How to create your own graph search using Neo4j jDays 2013 Ole-Martin Mørk 26/11/13
    • 3. ABOUT ME Ole-Martin Mørk Scientist Bekk Consulting AS Oslo, Norway twitter: olemartin
    • 4. AGENDA INTRODUCTION TO SEARCH INTRODUCTION TO NEO4J INTRODUCTION TO PARSING GRAPH SEARCH
    • 5. GRAF BETRAYS KNOWS KNOWS LOVES KNOWS
    • 6. NODE PERSON ADRESSE BODDE navn: Thomas alder: 24 gate: Aker nummer: 15
    • 7. RELASJON BODDE fra: til:
    • 8. RELASJONSDATABASER
    • 9. “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
    • 10. Neo4j
    • 11. GRAF C B A I D H E F G
    • 12. CYPHER
    • 13. GRAF C B A I D H E F G
    • 14. Cypher
    • 15. CYPHER ( ) --> ( )
    • 16. CYPHER a b (a) --> (b)
    • 17. CYPHER a b c (a)-->(b)<--(c)
    • 18. CYPHER a kjenner b (a) –[:kjenner]-> (b)
    • 19. 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)”)
    • 20. 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
    • 21. Grammar
    • 22. 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”
    • 23. TEXT PARSING CFG PEG
    • 24. GRAMMAR Alfred, who loved fishing, bought fish at the store downtown (Alfred, (who loved (fishing)), (bought (fish (at (the store (downtown))))))
    • 25. 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
    • 26. 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
    • 27. 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
    • 28. PARBOILED
    • 29. PARBOILED Parsing expression grammars parser Lightweight Easy to use Implementation in Scala and Java Rules are written in the programming language
    • 30. 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
    • 31. I went for a walk downtown Sequence( “I”, “went”, “for”, “a”, “walk”, “downtown”)
    • 32. 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”));
    • 33. went downtown today I for a walk walked to the city Sequence( …, Optional(String(“today”)));
    • 34. went downtown today for a walk today I walked to the city Sequence( Today(), …, Today()); Rule Today() { return Optional(String(“today”)); }
    • 35. 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.
    • 36. went downtown today for a walk today I walked to the city Sequence( …, FirstOf( Sequence(push(“downtown”), “downtown”, Sequence(push(“city”), “to the city”)));
    • 37. BEKK CV-db
    • 38. A search for Java yields 224 hits!
    • 39. 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() ) ) ) ); }
    • 40. 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
    • 41. Demo
    • 42. LEARN MORE graphdatabases.com neo4j.org bit.ly/neo-cyp parboiled.org
    • 43. ?
    • 44. Thank you! @olemartin

    ×