格莱姆林 .match()

3

我有一个在Datastax Studio中使用Gremlin编写的查询,看起来像这样:

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查询,但没有成功。

1个回答

3

您尝试过在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')

谢谢回答。我确实使用了 Union,但稍微改了一下。 - user5294007

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接