将 gremlin CLI 连接到远程tinkerpop gremlin-server

2024-01-08

Using 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'))

从 gremlin CLI 中,我可以设置TinkerGraph using

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

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

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

这也不完全是这样:

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

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


Gremlin Console 内置了对此的支持,并且有详细描述here http://tinkerpop.apache.org/docs/current/reference/#connecting-via-console。基本的连接命令是:

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

此时您可以对远程图进行遍历:

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

如果您想删除:>语法,您可以将 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

将 gremlin CLI 连接到远程tinkerpop gremlin-server 的相关文章

随机推荐