【问题标题】:Connecting gremlin CLI to a remote tinkerpop gremlin-server将 gremlin CLI 连接到远程 tinkerpop gremlin-server
【发布时间】:2019-03-30 14:11:35
【问题描述】:

使用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 使用

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 tinkerpop gremlin-server


    【解决方案1】:

    Gremlin 控制台已内置对此的支持,并在 here 中有详细描述。基本的连接命令是:

    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
    

    【讨论】:

    • 啊哈,我已经到了远程连接,但是我引用 g 的命令被弹回了。我需要输入console mode 再次感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-20
    • 1970-01-01
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多