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.
3.1 Adding a Vertex In Gremlin nodes are referred to as “Vertexes”. To add a node/vertex to the graph, you simply use the command addV() on your graph traversal source. For consistency, most people use “g” as their default graph traversal source. To append properties to your your vertex, you add a series of “.
On Linux and on Mac OS X typing CTRL-L will clear the screen.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With