Python TinkerPop:对多顶点类型的多级搜索

Python TinkerPop:对多顶点类型的多级搜索,python,tinkerpop3,gremlin-server,Python,Tinkerpop3,Gremlin Server,示例图: 查询:在第二跳中查找Marko的所有直接朋友(personVertex)和(union)所有软件 尝试失败: 一级人员的通用查询: 二级/hop软件的通用查询: gremlin> g.V(1).store('x').V(2).store('y').cap('x', 'y') ==>[x:[v[1]],y:[v[2]]] 尝试合并以上两个查询: 我真的不明白union是如何工作的,因为它不是合并数据 g.V(1).union().V(2) g.V(1).union(V(2

示例图

查询:在第二跳中查找Marko的所有直接朋友(
person
Vertex)和(union)所有
软件


尝试失败:

一级人员的通用查询:

二级/hop软件的通用查询:

gremlin> g.V(1).store('x').V(2).store('y').cap('x', 'y')
==>[x:[v[1]],y:[v[2]]]
尝试合并以上两个查询:

我真的不明白union是如何工作的,因为它不是合并数据

g.V(1).union().V(2)
g.V(1).union(V(2))
到目前为止,我得到的最好结果是,但我需要一些类似的能力(marko连接到个人和/或marko连接到软件):


这适用于第一级:

gremlin> g.V(1).hasLabel("person").as("from", "to1", "to2")
            .repeat(both()).times(1).emit(hasLabel("person")).hasLabel("person").as("to1")
            .select("from")
            .repeat(both()).times(1).emit(hasLabel("software")).hasLabel("software").as("to2")
            .project("from", "person", "software")
            .by(select("from").by("name"))
            .by(select("to1").by("name"))
            .by(select("to2").by("name"))
结果:

==>[from:marko,person:vadas,software:lop]
==>[from:marko,person:josh,software:lop]
对于多级,增加
倍的值

gremlin> g.V(1).store('x').V(2).store('y').cap('x', 'y')
==>[x:[v[1]],y:[v[2]]]
gremlin> g.V(1).hasLabel("person").as("from", "to1", "to2")
            .repeat(both()).times(1).emit(hasLabel("person")).hasLabel("person").as("to1")
            .select("from")
            .repeat(both()).times(1).emit(hasLabel("software")).hasLabel("software").as("to2")
            .project("from", "person", "software")
            .by(select("from").by("name"))
            .by(select("to1").by("name"))
            .by(select("to2").by("name"))
==>[from:marko,person:vadas,software:lop]
==>[from:marko,person:josh,software:lop]