Cosmos Graph Gremlin API 查询以接收同一对象中的顶点和边

问题描述 投票:0回答:0

我是新来的。

几个月来我一直在努力解决这个问题,但没有任何结果。

我有一个包含以下内容的 Cosmos Graph DB(Gremlin API)

  • #Root1

    • 儿童 1.1
      • 孩子 1.1.1
    • 儿童 1.2
      • 孩子 1.2.1
  • #Root2 .....

我想创建一个 qyery,在其中设置根 ID 并使用带有 Child 和 inE() 对象的对象生成结果。

例如

g.v('Root1').......

结果:

{"v" = Root1}
{"v" = Child1.1, "e" = <edge between Root1 and Child1.1>}
{"v" = Child1.1.1, "e" = <edge between Child1.1 and Child1.1.1>}
{"v" = Child1.2, "e" = <edge between Root1 and Child1.2>}
{"v" = Child1.2.1, "e" = <edge between Child1.2 and Child1.2.1>}

由于 Child 的深度不同,我想使用重复循环。

我试过这样的东西

g.V('Root1').repeat(outE().as('edge').inV().as('vertex')).times(2).emit().project('edge','vertex').by(select('edge')).by(select('vertex'))

我是它工作的第一步。但是当它变得更深时,它开始将所有边和顶点添加到数组 ex.

[
  {
    "v" : [{Child1.1},{"Child1.1.1}],
    "e" : [....]
  }.....
]

在 C# 的世界里,我会返回并在重复的边和顶点内对象,但我不知道该怎么做。

这是 Gremlin API 支持的东西吗?

gremlin azure-cosmosdb-gremlinapi
© www.soinside.com 2019 - 2024. All rights reserved.