Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Graph Analysis over JSON, Larus

GraphConnect Europe 2017
Omar Rampado, Larus

  • Login to see the comments

  • Be the first to like this

Graph Analysis over JSON, Larus

  1. 1. SINCE 2013
  2. 2. NEO4J JDBC DRIVER
  3. 3. APOC Developers Awesome Procedures On Cypher
  4. 4. Graph analysis over JSON data WEB API JSON FILE
  5. 5. CONTENTS • Document oriented DB and web API • Polyglot persistence • JSON • How Doc2Graph works • Connectors (CouchbaseDB, MongoDB) • Spotify API example • Configuration
  6. 6. Document oriented DBs and web APIs
  7. 7. Polyglot persistence Document is an aggregation of information: data are duplicated Graph is a relationship-oriented structure: data are connected Different approach for different use case
  8. 8. JSON Every (JSON) document is a tree structure Every tree structure is a sub graph Trees mixed together are a graph
  9. 9. JSON { id : “123”,
 name: “doc”,
 internalDoc : {
 id: “abc”,
 name : “iDoc”,
 languages: [“EN”,”IT”],
 }
 } id: “123”
 name: “doc” id: “abc”
 name: “iDoc”
 languages: [‘EN’,’IT’] [:IN_DOC]
  10. 10. JSON { id : “123”,
 name: “doc”,
 internalDoc : {
 id: “abc”,
 name : “iDoc”,
 languages: [“EN”,”IT”],
 }, refDoc : {
 id: “efg”,
 name : “extDoc”,
 }
 } id: “123”
 name: “doc” id: “abc”
 name: “iDoc”
 languages: [‘EN’,’IT’] [:IN_DOC] id: “efg”
 name:“extDoc [:IN_DOC]
  11. 11. Tree
  12. 12. Graph
  13. 13. Doc2Graph • Automatic synch • Customizable Transformation Logic • Re-use existing nodes • Import JSON from any kind of data source • Open Source
  14. 14. Re-using existing nodes id: “123”
 name: “doc” id: “abc”
 name: “iDoc”
 languages: [‘EN’,’IT’] [:IN_DOC] id: “456”
 name: “other” [:IN_DOC]
  15. 15. How it works A core installed into Neo4j: neo4j-json A optional jar with custom rules A configuration node A connector to external data source
  16. 16. How it works CALL json.upsert(‘document-key’,’{json: …}’); CALL json.delete(‘document-key’);
  17. 17. CouchbaseDB connector
  18. 18. MongoDB connector
  19. 19. Spotify API example https://api.spotify.com/v1/artists/{id} https://api.spotify.com/v1/albums/{id} https://api.spotify.com/v1/tracks/{id}
  20. 20. Spotify API example 1. neo4j start 2. java -jar target/neo4j-connector.jar -Dconf.file=neo4j-sync.propeties 3. ./cbdocloader -n localhost:8091 -u ad -p ps -b spotify artists.zip 4. ./cbdocloader -n localhost:8091 -u ad -p ps -b spotify tracks.zip 5. ./cbdocloader -n localhost:8091 -u ad -p ps -b spotify albums.zip
  21. 21. Spotify API example { "id" : "00D4HkSczu4DJP5PCkVOiX", "name" : "Spaceship Coupe", "type" : “track”, "album" : { "name" : "The 20/20 Experience - The Complete Experience", "type" : “album", "id" : "3Xli4SFIUo8GAr4f6yORHr", "artists" : [ { "id" : "31TPClRtHm23RisEBtV3X7", "name" : "Justin Timberlake", "type" : "artist", } ], "artists" : [ { "id" : "31TPClRtHm23RisEBtV3X7", "name" : "Justin Timberlake", "type" : “artist" } ] }
  22. 22. Spotify API example match p=(daddy:Artist {name:'Daddy Yankee'})--(alb:Album)--(oth:Artist) return p
  23. 23. Spotify API example { "id" : "omar", "type" : "user", "name" : "Omar Rampado", "preferred_album" : { "id" : "3HArmgjL01OKFTLfU1HJiQ", "name" : "Otra Cosa", "type" : "album", "href" : "https://api.spotify.com/v1/albums/3HArmgjL01OKFTLfU1HJiQ", "uri" : "spotify:album:3HArmgjL01OKFTLfU1HJiQ", "album_type" : "single", "available_markets" : [“CO","DO","EC","PE","US"] } }
  24. 24. Spotify API example match p=(daddy:Artist {name:'Daddy Yankee'})--(alb:Album)--(oth:Artist) , (omar:User {id: 'omar'})--(alb) return p, omar
  25. 25. Configuration CREATE (n:JSON_CONFIG { configuration: 'byNode' ,root_node_key_property:'_document_key' ,document_default_label:'DocNode' ,document_id_builder:'org.neo4j.helpers.json.document.impl.DocumentIdBuilderTypeId' ,document_relation_builder:'org.neo4j.helpers.json.document.impl.DocumentRelationBuilderH asTypeArrayKey' ,document_label_builder:'org.neo4j.helpers.json.document.impl.DocumentLabelBuilderByType' ,log_discard_events: false })
  26. 26. LINKS http://www.larus-ba.it/neo4j/en/projects/doc2graph/ https://github.com/larusba/doc2graph

×