Gremlin select 多个顶点给出了一个没有空值属性的输出

Gremlin select multiple vertices gives an output without the properties with null values

为了从两个顶点 a 和 b 获取所有数据,我使用了以下内容

 g.V('xxx').out('hasA')..as('X').out('hasB').as('Y').select('X','Y').

我得到 X 的值,而 Y 的值不是 null.I 想要得到所有 X,其中 Y 的值可以是也可以不是 null。

关于如何调整上述查询有什么想法吗?

我不确定这对您是否更重要,但要直接回答您的问题,您需要处理没有“hasB”边的可能性。您可以按以下方式使用 coalesce() 执行此操作:

g.V('xxx').out('hasA').as('X').
  coalesce(out('hasB'),constant('n/a')).as('Y').
  select('X','Y')