PuppyGraph
Search
K
Comment on page

Getting Started

Prerequisites

Make sure that the PuppyGraph has been deployed following AMI Version or Docker Deployment.

Set Username and Password

You can then access PuppyGraph in your browser with the URL http://<hostname>:8081. For example, a locally deployed PuppyGraph is available at http://localhost:8081.
First, login PuppyGraph with the default username and passowrd.
Username
puppygraph
Password
888888
You may want to update the username and password. Click the "reset admin credentials" button to reset the username and password.
In this example, we will use the default username puppygraph and the password is 888888.
INFO[06:38:21] username password not initialized, please follow the instructions to configure
input username [default: puppygraph]: puppygraph
puppygraph
input password [default: ]: ******
INFO[06:38:52] password updated successfully, please restart the console
Refresh the page to restart the console. After logging in with the username and password, you will see PuppyGraph management UI.
PuppyGraph UI

Graph Creation and Query

We now demonstrate how to load a graph into PuppyGraph and query its data.
The demo loads the data into PuppyGraph itself. For use cases where PuppyGraph connects to external data sources, please see: Query Data Lakes and Query Databases.

Example Graph

In this demo, we use a graph with 6 vertices and 6 edges:
example graph
We provided a shortcut to setup the schema and data for the example graph. Click the "Try demo schema and data" button and they graph will setup automatically for you.
Click the demo button to automatically setup demo graph
After setup, you can view the schema on the web UI. You will find the graph has 2 vertex types and 2 edge types.
View schema
When do manually, it requires two steps to make this graph ready in PuppyGraph. You can refer to the setup-demo-graph-manually.

Query the Graph

Query using Gremlin

Query with Embedded Gremlin Console

PuppyGraph provides an embedded Gremlin console.
Start Gremlin console from the UI
It then starts a Gremlin Console like the following:
Welcome to PuppyGraph, type help to see the command list
[PuppyGraph]> console
INFO: Created user preferences directory.
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
gremlin>
The following sample query asks for all the "names" of the nodes in the Graph.
g.V().values("name")
And the output will be like this:
gremlin> g.V().value("name")
==>vadas
==>peter
==>marko
==>josh
More examples:
gremlin> g.V('person:::v1')
==>v[person:::v1]
gremlin> g.V('person:::v1').values('name')
==>marko
gremlin> g.V('person:::v1').outE('knows')
==>e[knows:::e7][person:::v1-knows->person:::v2]
==>e[knows:::e8][person:::v1-knows->person:::v4]
gremlin> g.V('person:::v1').out('knows').values('name')
==>josh
==>vadas
gremlin> g.V('person:::v1').out('knows').has('age', gt(30)).values('name')
==>josh
gremlin> :x
[PuppyGraph]>

Query with Java Client

In order to connect with Java Client, the following dependencies have to be added into Java dependency.
pom.xml
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-server</artifactId>
<version>3.6.0</version>
</dependency>
The following is an example of connection Gremlin Server.
public class TestGraphBinaryMessageSerializerV1 {
public static void main(String[] args) throws Exception {
Cluster cluster = Cluster.build().addContactPoint("127.0.0.1").create();
Client client = cluster.connect();
GraphTraversalSource g = AnonymousTraversalSource.traversal()
.withRemote(DriverRemoteConnection.using(client, "g"));
System.out.println(g.V().count().next());
System.out.println(g.E().count().next());
System.out.println(g.V("person:::v1").values("name").next(10));
g.close();
client.close();
cluster.close();
return;
}
}

Query with Python Client

It is recommended to use official gremlin-python client.
python3 -m pip install gremlinpython
After installation, you can query the local Gremlin server using the the native driver.
from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
g = traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
print(g.V().name.toList())
# ['ripple', 'lop', 'josh', 'peter', 'vadas', 'marko']
print(g.V().hasLabel('person').name.toList())
# ['vadas', 'peter', 'marko', 'josh']
print(g.V('person:::v1').out('knows').name.toList())
# ['josh', 'vadas']
It is also possible to submit the query directly so that the query string is consistent with the one used in the Gremlin console.
from gremlin_python.driver import client
result_set = client.submit('g.V().values("name")')
print(result_set.all().result())
# ['ripple', 'lop', 'marko', 'peter', 'vadas', 'josh']
result_set = client.submit('g.V().hasLabel("person").values("name")')
print(result_set.all().result())
#['marko', 'vadas', 'peter', 'josh']
client.close()

Query using Cypher

PuppyGraph also provides an embedded Cypher console.
The output will be like this
Welcome to PuppyGraph, type help to see the command list
[PuppyGraph]> cypher-console
\,,,/
(o o)
-----oOOo-(3)-oOOo-----
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
plugin activated: tinkerpop.tinkergraph
==>opencypher.gremlin activated
==>Configured localhost/127.0.0.1:8182
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin>
Here is a sample query that matches the Gremlin query above. Make sure to include :> prefix in the cypher query input text.
:> MATCH (p:person) RETURN p.name
Output will be like this:
gremlin> :> MATCH (p:person) RETURN p.name
==>[p.name:josh]
==>[p.name:peter]
==>[p.name:vadas]
==>[p.name:marko]
Last modified 11d ago