IBM/janusgraph-utils

Name: janusgraph-utils

Owner: International Business Machines

Description: Develop a graph database app using JanusGraph

Created: 2017-04-23 08:56:06.0

Updated: 2018-05-23 04:36:48.0

Pushed: 2018-05-01 23:40:12.0

Homepage: https://developer.ibm.com/code/patterns/develop-graph-database-app-using-janusgraph/

Size: 832

Language: Java

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Build Status

Develop a graph database app using JanusGraph

This Code Pattern contains sample data and code for running a Twitter-like application in JanusGraph. The utility code illustrates how to use OLTP APIs to define schema, ingest data, and query graph. Developers can use or modify the code to build and operate their custom graph applications, or create similar java and groovy files to interact with JanusGraph.

When the reader has completed this Code Pattern, they will understand how to:

Flow

Prerequisites: Install and configure JanusGraph, Cassandra, ElasticSearch, janusgraph-utils

  1. The user generates Twitter sample schema and data using JanusGraph utilities
  2. The user loads schema and imports data in backend servers using JanusGraph utilities
  3. The user makes search and update requests in a REST/custom client
  4. The client app sends the REST requests to JanusGraph server
  5. The JanusGraph server interacts with backend to process and return graph data
Included components
Featured technologies

Watch the Video

Steps

Run locally
  1. Install prerequisites
  2. Clone the repo
  3. Generate the graph sample
  4. Load schema and import data
  5. Run interactive remote queries
1. Install prerequisites

NOTE: These prerequisites can be installed on one server. The instructions are written for Cassandra 3.10 and ElasticSearch 5.3.0 on Linux. Newer versions should work, but might not have been tested. The folder structures on Mac can be different. Check Cassandra and ElasticSearch official documentations for details.

Install Cassandra 3.10 on the storage server. Make the following changes in /etc/cassandra/cassandra.yaml and restart Cassandra.

t_rpc: true
address: 0.0.0.0
port: 9160
dcast_rpc_address: x.x.x.x (your storage server ip)

Install ElasticSearch 5.3.0 on the index server. Make the following changes in /etc/elasticsearch/elasticsearch.yml and restart ElasticSearch.

ork.host: x.x.x.x (your index server ip)

Install JanusGraph on the graph server:

Install a REST client, such as RESTClient add-on for Firefox, on the client machine.

2. Clone the repo

Clone the janusgraph-utils on the graph server and run mvn package.

clone https://github.com/IBM/janusgraph-utils.git
anusgraph-utils/
package
3. Generate the graph sample

Run the command in janusgraph-utils folder to generate data into /tmp folder.

n.sh gencsv csv-conf/twitter-like-w-date.json /tmp

Modify the generated user file under /tmp so the sample queries will return with data.

-i -e '2s/.*/1,Indiana Jones/' /tmp/User.csv
4. Load schema and import data

A graph schema can be loaded from either the Gremlin console or a java utility. You can check the doc doc/users_guide.md for details. Alternatively, just run one command in janusgraph-utils folder to load schema and import data.

rt JANUSGRAPH_HOME=~/janusgraph
n.sh import ~/janusgraph/conf/janusgraph-cql-es.properties /tmp /tmp/schema.json /tmp/datamapper.json
5. Run interactive remote queries

Configure JanusGraph server by running these commands:

/janusgraph/conf/gremlin-server
/janusgraph-utils/samples/date-helper.groovy ../../scripts
./janusgraph-cql-es.properties janusgraph-cql-es-server.properties
remlin-server.yaml rest-gremlin-server.yaml

Add this line to janusgraph-cql-es-server.properties:

lin.graph=org.janusgraph.core.JanusGraphFactory

Change the following four lines in rest-gremlin-server.yaml:

: x.x.x.x (your server ip)
nelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
h: conf/gremlin-server/janusgraph-cql-es-server.properties}
pts: [scripts/empty-sample.groovy,scripts/date-helper.groovy]}}

Start JanusGraph server:

/janusgraph; ./bin/gremlin-server.sh ./conf/gremlin-server/rest-gremlin-server.yaml

Now you can query and update graph data using REST. For example, send REST requests using RESTClient in browser with following:

od: POST
 http://x.x.x.x:8182
: {"gremlin":?query_to_run"}

You can find sample search and insert queries in samples/twitter-like-queries.txt.

Sample output

Sample output for "Find Indiana Jones' tweets that his followers retweeted"

Links

Learn more

License

Apache 2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.