获取 Neptune 数据库中不使用 map step() 的 Gremlin 查询语句中边的起始节点和结束节点的 ID。

3
我正在使用 Neptune AWS,想要找出边的起始节点 ID 和结束节点 ID。对于 Neo4j,Map 步骤是可行的,但同样的查询在 Neptune 上无法工作。
数据示例:点击此处 查询内容:
   query = """g.V().hasLabel('Person').has("name", "marko").as("from", "to")
        .repeat(bothE().as("e").otherV().as("to").as("to")).times(2).emit(hasLabel("Person")).hasLabel("Person").has("name", "josh")
        .project("name",  "Label","start", "end")
        .by(select(all, "to").unfold().values("title").fold())
        .by(select(all, "to").unfold().label().fold())
        .by(select(all, "e").unfold().id().map{g.E(it.get()).next()}.outV().id().fold())
        .by(select(all, "e").unfold().id().map{g.E(it.get()).next()}.inV().id().fold())
    """

这在Neptune上出现了错误,但在Neo4j上可以正常工作。是否有其他方法来获取起始节点和结束节点的ID?

1个回答

3
我不确定我是否明白为什么你需要这样做:
.by(select(all, "e").unfold().id().map{g.E(it.get()).next()}.outV().id().fold())

这难道不是简化为:
.by(select(all, "e").unfold().outV().id().fold())

那样做可以消除lambda函数,我想这就是你对Neptune的问题所在。

是的,我知道了,在去掉映射步骤后它的工作方式相同。谢谢。 - Ravindra Gupta

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接