Rahul Dabas
Rahul Dabas

Reputation: 726

Connect to Titan Graph DB with TinkerPop3 Restful Interface

I am very new to Titan/Gremlin/TinkerPop3 and am playing around/experimenting with Restful API Interface to create/modify/delete vertices/edge in database.

I basically want to see if its possible to use the API exposed by tinkerpop3 for graph processing.

I created the modern graph in gremlin server using:

gremlin> graph = TinkerFactory.createModern()
gremlin> g = graph.traversal()

I am able to connect to Titan via restful API and execute:

curl "http://localhost:8182?gremlin=100-1"
{"requestId":"c2dfb667-0fbe-4796-9a5b-cc472487a5b0","status":{"message":"","code":200,"attributes":{}},"result":{"data":[99],"meta":{}}}

But the following doesn't return anything:

curl http://localhost:8182 -d '{"gremlin": "g.V()"}'
{"requestId":"8ba30f35-31e7-46ff-b16e-3e01fb9a49bf","status":{"message":"","code":200,"attributes":{}},"result":{"data":[],"meta":{}}}

I did my reading from: http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#_connecting_via_rest

Any help is very appreciated. Thanks in advance.

Upvotes: 2

Views: 1207

Answers (1)

Jason Plurad
Jason Plurad

Reputation: 6792

When you were interacting with the Gremlin Console initially, you created an in-memory TinkerGraph. You were not interacting with the Gremlin Server at all, so when you exited the console, that graph was lost.

The graph(s) served by Gremlin Server are configured in the gremlin-server.yaml file. Its configuration is described more in-depth in the TinkerPop documentation.

If you take a look at this example configuration from TinkerPop, the graph configuration is for an empty TinkerGraph, but there is an additional script that loads the modern graph. To run with this configuration, pass it as an argument when starting the server:

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

This same approach can be used with Titan as well, but I'd highly recommend learning TinkerPop first before going deeper with Titan. TinkerPop provides a substantial foundation for the graph structure and query infrastructure for Titan.

Upvotes: 5

Related Questions