Gremlin 根据出顶点的特定子集上的出边数查询 select 个顶点

Gremlin query to select vertex based on count of out edges on a particular subset of out vertex

例如,Graph中有两种类型的顶点[ Account , User]。帐户顶点有到用户顶点的边,表示用户列表形成一个帐户顶点。 用户顶点有两个 属性 (name, phoneNumber)。我想要 select 个连接到超过 2 个名称以 foo 开头的用户的帐户。

输出不应包含与用户顶点有 2 条以上边的帐户,但在所有这些用户中,只有 1 个用户名以 foo 开头。至少,2 个用户的名称应以 foo 开头。

这个查询可以做到:

g.V().hasLabel("Account")
.where(out().hasLabel("User")
.has("name", startingWith("foo"))
.count().is(gte(2)))