代码之家  ›  专栏  ›  技术社区  ›  iRyanBell

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

  •  0
  • iRyanBell  · 技术社区  · 6 年前

    使用 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连接到此服务器?

    1 回复  |  直到 6 年前
        1
  •  10
  •   stephen mallette    6 年前

    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置于“console”模式,并且不再需要该前缀:

    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