【问题标题】:Add a one to many edge - Tinkerpop (3.0.1)添加一对多边缘 - Tinkerpop (3.0.1)
【发布时间】:2017-07-16 00:52:19
【问题描述】:

如何在一次调用中将一条边从一个顶点添加到多个顶点?我知道我可以使用单个顶点调用通常的 addEdge,但我想避免为我需要添加的每个边缘调用 gremlin 服务器,因为可能有很多。

这在 3.2.3 版本中有效,但 V 方法在 3.0.1 版本中不可用,因此希望以另一种方式复制它。

// Get vertices I want to add edge to
g.V().has("id",within(["2","3","4"])).as("toV").

// Now get the vertex I want to add edge from
V("1").as("fromV").

// And add an edge between them
addE("likes").from("fromV").to("toV")

【问题讨论】:

  • 您使用哪个版本的 TinkerPop?您的最后一个查询使用 v3.2.x 应该没问题。
  • 由于 dynamodb 存储后端,我现在被困在 3.0.1-incubating 上。
  • 答案已更新以反映这一点。

标签: amazon-dynamodb titan gremlin tinkerpop3 gremlin-server


【解决方案1】:

这是addEdge step 上来自 TinkerPop 3.0.1 的文档,您可以在那里找到一个示例,了解您可以在 Titan 1.0 中使用的语法。您可以在 Gremlin 控制台中对此进行测试。

graph = TitanFactory.open('inmemory'); g = graph.traversal()
g.addV('name', '1').addV('name', '2').addV('name', '3').addV('name', '4')
g.withSideEffect('a', g.V().has('name', within('2', '3', '4')).toList()).
    V().has('name', '1').addOutE('likes', 'a')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-26
    • 2018-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多