示例图:Tinker Modern
查询:在第二跳中查找Marko的所有直接好友(person
顶点)和(union)所有software
。你知道吗
失败的尝试:
Generic Query for first level people:
g.V(1).hasLabel("person").repeat(both()).times(1).emit(hasLabel("person")).hasLabel("person").values("name")
Generic Query for second level/hop software:
g.V(1).hasLabel("person").repeat(both()).times(2).emit(hasLabel("software")).hasLabel("software").values("name")
Attempt to merge above two queries:
g.V(1).hasLabel("person").repeat(both()).times(1).emit(hasLabel("person")).hasLabel("person").repeat(both()).times(2).emit(hasLabel("software")).hasLabel("software").values("name")
我不太明白union是如何工作的,因为它不是合并数据。你知道吗
g.V(1).union().V(2)
g.V(1).union(V(2))
到目前为止,我得到的最好结果是,但我需要一些这样的能力(marko connected to person和/或marko connected to software):
gremlin> g.V(1).store('x').V(2).store('y').cap('x', 'y')
==>[x:[v[1]],y:[v[2]]]
第一级:
结果:
对于多层,增加
times
的值相关问题 更多 >
编程相关推荐