将gremlin CLI连接到远程tinkerpop gremlin服务器

iRy*_*ell 1 gremlin tinkerpop gremlin-server

使用gremlin-javascript,我正在使用以下方法连接到远程服务器:

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'))
Run Code Online (Sandbox Code Playgroud)

从小鬼CLI,我可以设置一个TinkerGraph使用

gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal()
Run Code Online (Sandbox Code Playgroud)

但是,我想通过连接到我的图表localhost:8182。这并不能完全解决问题:

gremlin> graph = RemoteGraph.open('ws://localhost:8182/gremlin')
Run Code Online (Sandbox Code Playgroud)

而且也不是这样:

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

如何从CLI连接到该服务器?

ste*_*tte 5

Gremlin Console内置了对此的支持,并在此处详细描述。基本的连接命令是:

gremlin> :remote connect tinkerpop.server conf/remote.yaml
==>Configured localhost/127.0.0.1:8182
Run Code Online (Sandbox Code Playgroud)

在这一点上,您可以对远程图形进行遍历:

gremlin> :> g.V().values('name')
==>marko
==>vadas
==>lop
==>josh
==>ripple
==>peter
Run Code Online (Sandbox Code Playgroud)

如果您想删除:>语法,则可以将REPL置于“控制台”模式,并且不再需要该前缀:

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
Run Code Online (Sandbox Code Playgroud)