【发布时间】:2020-08-05 11:22:58
【问题描述】:
假设我有这个示例数据
Vertex[type: Person, name: Foo] ---hasPet---> Vertex[type: Dog, name: Dog1]
Vertex[type: Person, name: Bar] ---hasPet---> Vertex[type: Cat, name: Cat1]
Vertex[type: Person, name: Bazz] ---hasPet---> Vertex[type: Dog, name: Dog2]
Vertex[type: Person, name: Bazz] ---hasPet---> Vertex[type: Dog, name: Dog3]
然后我想找到至少有宠物的任何人型顶点是狗。
如何在不遍历所有非人类型顶点的情况下找到所有这些人类型顶点?
我尝试了这个查询,但它仍在遍历Bazz 的所有宠物,我想在找到任何匹配项后立即停止遍历,因为Bazz 可能还有数千个其他宠物。
我的查询:
g.traversal().V().has("type", "Person").repeat(out("hasPet").simplePath()).until(has("type", "Dog")).simplePath().in().valueMap("name")
结果如下:
[Foo]
[Bazz]
[Bazz]
我喜欢的是:
[Foo]
[Bazz]
【问题讨论】:
标签: gremlin janusgraph