我在Gremlin中有一个查询,使用的是Datastax studio,如下所示:
g.V().has('vertexLabel', 'vertexProperty1', '12345').match(
__.as('d').in('edgeLabel1').values('property2').as('NAME1'),
__.as('d').in('edgeLabel2').values('property3').as('NAME2'),
__.as('d').in('edgeLabel1').out('edgeLabel3').values('property4').as('NAME3')
).select('NAME1', 'NAME2', 'NAME3')
如果所有实体都存在,这种方法就可以很好地工作,但如果其中一个实体不在图形上,即使我知道有,也找不到结果。如果这些值存在,我如何进行.or查询来查找它们。比方说,如果在edgeLabel3的末尾没有找到property4,我的查询怎么还能给出另外两个结果(property2和property3)呢?我尝试过执行.or查询,但一直没有成功。
发布于 2017-07-10 00:42:24
你试过在Gremlin中使用union步骤吗?它应该看起来像这样:
g.V('book:882178048:25').has('vertexLabel', 'vertexProperty1', '12345')
.union(
as('d').in('edgeLabel1').values('property2').store('NAME1'),
as('d').in('edgeLabel2').values('property3').store('NAME2'),
as('d').in('edgeLabel1').out('edgeLabel3').values('property4').store('NAME3')
).cap('NAME1', 'NAME2', 'NAME3')
https://stackoverflow.com/questions/44980542
复制相似问题