问题描述
使用gremlin-javascript
,我正在使用以下方式连接到远程服务器:
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'))
在gremlin CLI中,我可以使用
From the gremlin CLI, I can setup a TinkerGraph
using
gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal()
但是,我想在localhost:8182
处连接到我的图形.这并不能完全解决问题:
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')
这也不尽然:
gremlin> graph = TinkerGraph.open()
gremlin> g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'))
如何从CLI连接到该服务器?
How would I connect to this server from the CLI?
推荐答案
Gremlin Console内置了对此的支持,并在此处.基本的连接命令是:
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
如果您想放弃:>
语法,则可以将REPL置于控制台"模式,并且不再需要该前缀:
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
这篇关于将gremlin CLI连接到远程tinkerpop gremlin服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!