【问题标题】:Can strategies be used with remote traversal in Gremlin?Gremlin 中的远程遍历可以使用策略吗?
【发布时间】:2017-07-04 13:53:48
【问题描述】:

我正在使用带有远程模式的 Gremlin-Java 与 JanusGraph 进行交互。我现在在边缘上定义一个新属性,以便在使用特定策略时过滤它们。 以下是我试图在我的应用程序中运行的代码,但该策略似乎被完全忽略了。在本地 TP 实例上执行的相同代码正在运行。

graph.traversal()
    .withRemote(DriverRemoteConnection.using(cluster, "g"))
    .withStrategies(SubgraphStrategy.build().edges(__.has("field", "condition")).create())

有人知道这个功能是否仍然不受支持?我正在使用 Janus 0.1.0。

【问题讨论】:

    标签: gremlin tinkerpop3 janusgraph


    【解决方案1】:

    这似乎是 Apache TinkerPop 中的一个错误。我opened an issue 来跟踪这个。

    一种解决方法是将远程驱动程序配置配置为使用 GraphSON 序列化程序而不是 Gryo。这不需要对服务器配置进行任何更改。例如在conf/remote-objects.yaml:

    hosts: [localhost]
    port: 8182
    serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV2d0,
              config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] } }
    

    另一种解决方法是在 Gremlin 服务器脚本中定义另一个遍历源。例如,如果您使用默认的conf/gremlin-server/gremlin-server.yaml,请更新scripts/empty-sample.groovy 中的全局绑定:

    // define the default TraversalSource to bind queries to - named "g".
    // define a subgraph traversal source - named "sg"
    globals << [g : graph.traversal(),
        sg: graph.traversal().withStrategies(SubgraphStrategy.build().edges(
            __.has("field", "condition")).create())]
    

    然后你可以利用远程驱动程序的遍历源:

    cluster = Cluster.open('conf/remote-objects.yaml')
    graph = EmptyGraph.instance()
    sg = graph.traversal().withRemote(DriverRemoteConnection.using(cluster, "sg"))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-29
      • 2017-12-04
      • 2021-12-21
      • 2013-03-01
      • 2020-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多