使用 Gremlin 针对 Azure Cosmos 数据库图将边限制到同一组顶点的最佳方法

Best way to limit edges to the same group of verices using Gremlin against Azure Cosmos db graph

我需要通过属性上的特定谓词过滤顶点,以及它们之间存在的所有边(具有特定标签,可能还有一些关于边属性的谓词)。

这是针对 Cosmos Azure Db 图的,解决方案应该是单个 Gremlin 查询。

到目前为止,我正在考虑以下内容:

g.V().has('property1', value1).has('property2', value2).select('vertices')
.outE().as('edges').inV().has('property1', value1).has('property2', value2)
.select('vertices','edges')

有没有更好的方法来实现这个?

鉴于描述和您的评论,此遍历应该适合您:

g.V().has('property1', value1).has('property2', value2).
  aggregate('v').
  outE().                   /* add edge filters here */
  inV().where(within('v')).
  path().
  union(union(limit(local, 1),
              tail (local, 1)).dedup().aggregate('vertices'),
        range(local, 1, 2).aggregate('edges')).
  cap('vertices','edges').next()