18

I remotely connect to a gremlin server using gremlin-console(which is janusgraph), but when I create a variable and access it, it doesn't work. My ultimate goal is to use gremlin-console to create index...

gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - 
[localhost/127.0.0.1:8182] - type ':remote console' to return to local mode
gremlin> a = "b"
==>b
gremlin> a
No such property: a for class: Script3
Type ':help' or ':h' for help.
Gao
  • 912
  • 6
  • 16

2 Answers2

23

You can't use variables like this for subsequent requests, because the console is by default sessionless. So every request is executed in its own transaction and no state is shared between two different requests.

However you can configure the console to use a session by simply appending the session keyword to the connect argument:

gremlin> :remote connect tinkerpop.server conf/remote.yaml session
==>Configured localhost/127.0.0.1:8182-[15dc7030-0e5b-4b4b-a997-9d2cf519ebb2]
gremlin> :> x = 1
==>1
gremlin> :> y = 2
==>2
gremlin> :> x + y
==>3

I copied this example from the TinkerPop documentation for this topic.

Florian Hockmann
  • 2,634
  • 13
  • 24
3

Download janusdb and launch the gremlin console by running

/bin/gremlin.sh

Construct the janus graph using the following command:

gremlin> graph = JanusGraphFactory.open('conf/janusgraph-cassandra-solr.properties')

Get your graph traversal source by running:

gremlin> g = graph.traversal()

Now you are connected directly to the database with the full control. You can store the return values and use it in the next queries.

Chandran Anjur
  • 119
  • 1
  • 3