Giter Club home page Giter Club logo

onsdigital.dp-neptune-spike's Introduction

Neptune Spike

Useful notes on getting started including links to tutorials.

General Info

Gremlin getting started

Beginner tutorials on using the gremlin console and basic query syntax:

http://tinkerpop.apache.org/docs/3.3.3/tutorials/getting-started/

Set up gremlin console to use remote server

Example of how to set up the gremlin console to point to a remote server:

https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-console.html

Java Gremlin example

Getting started example of using the java library

https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-java.html

Some AWS specific Gremlin implementation notes:

https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html

Running dp-neptune-spike

Assuming a Neptune instance is running and an EC2 instance is all set up.

Open an ssh tunnel to the EC2 box:

Curently the EC2 is not exposed publically so to connect to Neptune you need to open an ssh tunnel to forward requests to localhost:8182 to EC2 - you will need to keep this open.

ssh -i ~/.ssh/ons-web-development.pem -L 8182:<AWS_NEPTUNE_ENDPOINT>:8182 ec2-user@<AWS_EC2_PORT>

Install Gremlin console on the EC2 instance

Gremlin console is a terminal tool which allows you query the database. Follow the AWS steps to set it up. (Including the instuctions on how to connect to a remote DB):

https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-console.html

Install Gremlin server on the EC2 instance

From your home directory on the EC2 box run:

wget https://archive.apache.org/dist/tinkerpop/3.3.2/apache-tinkerpop-gremlin-server-3.3.2-bin.zip
unzip apache-tinkerpop-gremlin-server-3.3.2-bin.zip
cd apache-tinkerpop-gremlin-server-3.3.2

Start the server and point it at your AWS Neptune instance.

./bin/gremlin-server.sh conf/gremlin-server.yaml

From your machine if you curl localhost:8182 you should get a response similar to:

{
  "requestId": "38b2c520-d97a-f5ff-414e-7d9a5c6de398",
  "code": "MissingParameterException",
  "detailedMessage": "no gremlin script supplied"
}

You are successfull able to hit the Gremlin server running on the EC2 instance (whoop!)

Run the app

The app is as basic as it comes and simply takes input from the console and uses the gremlin client to send queries to the gremlin server. Simply type in your query and hit enter (or enter exit to quit).

From the project root

Build it

mvn clean package -DskipTests=true 

Run it

java -jar target/dp-neptune-spike-1.0-SNAPSHOT.jar -query

Execute a query (see the gremlin tutorials for syntax)

grem-query> g.addV("person").property("name", "Dave").next()
grem-query> g.V().valueMap(true)
> {id=50b2c521-8a91-457f-4a82-eb4d29c6ef67, label=person, name=[Dave]}

The above example runs 2 queries, the first creates a new vertex labelled "person" with a name property "Dave". The second queries for all vertices and returns them with all their properties and labels - which in this case returns the vertex created in the previous query.

onsdigital.dp-neptune-spike's People

Contributors

daillew avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.