Connecting gremlin CLI to a remote tinkerpop gremlin-server

只谈情不闲聊 提交于 2019-12-24 08:17:27

问题


Using gremlin-javascript, I'm connecting to a remote server using:

const gremlin = require('gremlin')
const Graph = gremlin.structure.Graph
const DriverRemoteConnection = gremlin.driver.DriverRemoteConnection
const graph = new Graph()

const g = graph
  .traversal()
  .withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'))

From the gremlin CLI, I can setup a TinkerGraph using

gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal()

However, I'd like to connect to my Graph at localhost:8182. This doesnt't quite do the trick:

gremlin> graph = RemoteGraph.open('ws://localhost:8182/gremlin')

And this isn't quite it either:

gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'))

How would I connect to this server from the CLI?


回答1:


Gremlin Console has built in support for this and it is described in detail here. The basic connection command is:

gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182

at which point you can issue traversals against the remote graph:

gremlin> :> g.V().values('name')
==>marko
==>vadas
==>lop
==>josh
==>ripple
==>peter

If you'd like to drop the :> syntax you can put the REPL in "console" mode and that prefix will no longer be necessary:

gremlin> :remote console
==>All scripts will now be sent to Gremlin Server - [localhost/127.0.0.1:8182]-[5ff68eac-5af9-4140-b3b8-d9311f30c053] - type ':remote console' to return to local mode


来源:https://stackoverflow.com/questions/52998174/connecting-gremlin-cli-to-a-remote-tinkerpop-gremlin-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!