cegprakash
cegprakash

Reputation: 3125

Using gremlin-python Janus for social networking application

I'm getting started with graph databases. I want to migrate a social networking application from sql to Janus Graph database. I plan to build the application using Python Django framework.

I also plan to scale the application using using IBM's ComposeForJanusGraph in the future.

Problems I face:

1) I'm following the tinkerpop documentation for gremlin_python and I face several issues with the syntax because I couldn't find any good documentation. Only documentation I found here is also very short and not that helpful of how to do a CRUD. (For example how to create a new database, how to configure the search or storage database, how to create a node, how to create an edge, how to query for a vertex with a specific edge is not documented well clearly. None of them works when I try myself.)

2) Is there anything I should know before I learn and build it?

Upvotes: 2

Views: 850

Answers (1)

stephen mallette
stephen mallette

Reputation: 46216

I couldn't find any good documentation. Only documentation I found here is also very short and not that helpful

Gremlin is Gremlin is Gremlin. It doesn't matter if it's Python or Java or C# or Javascript - it's all just Gremlin. Therefore, the documentation for Gremlin using Python is "short" because it simply shows how you initiate your GraphTraversalSource that allows you to spawn Traversal instances. From there, you have access to all the standard steps that Gremlin offers:

http://tinkerpop.apache.org/docs/current/reference/#graph-traversal-steps

and therefore the remainder of the documentation basically applies to your needs. The main bit of trickery to consider is that some step names conflict with Python reserved words - in those case, the step is post-fixed with a underscore and thus, the in() step for Java becomes in_() in Python.

For example how to create a new database, how to configure the search or storage database,

You won't find this in TinkerPop documentation really. How you create/configure a TinkerPop Graph implementation is specific to the graph database that you choose. You typically won't do that in Python. You will resort to the approach provided by your graph. If your graph is JanusGraph on IBM Compose, you should consult their documentation. You will only connect to that graph once established with gremlin-python.

how to create a node, how to create an edge,

It's just Gremlin. Gremlin has steps for mutating a Graph so to add a vertex and and to add an edge so to create two vertices and an edge between them I can string together a single traversal that does that:

g.addV('person').property('name','cegprakash').as('c').
  addV('question').property('title','Using gremlin-python Janus for social networking application').as('q1').
  addV('question').property('title','Working of CCD algorithm for Inverse Kinematics').as('q2').
  addE('asks').property('votes',0).from('c').to('q1').
  addE('asks').property('votes',1).from('c').to('q2').iterate()

how to query for a vertex with a specific edge is not documented well clearly.

Again, it's just Gremlin and there are plenty of examples.

g.V().has('person','name', 'cegprakash').
  out('asks').
  has('votes',gt(0))

So the above, says to find a vertex with the name "cegprakash", then traverse all the outgoing edges labelled "ask" with a "vote" property that has values greater than zero.

Is there anything I should know before I learn and build it?

If you haven't worked with graphs before, just start simple. Use TinkerGraph and the Gremlin Console to get familiar with the Gremlin language and then start looking into how JanusGraph is configured and operated under Compose. At that point you'll have a good basis for digging into how your application will actually work and if necessary asking more specific questions.

Upvotes: 4

Related Questions