简体   繁体   English

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

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

In order to get all data from two vertices a and bi used the following为了从两个顶点 a 和 bi 获取所有数据,使用以下命令

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

I get values of X where the value of Y isnt null.I wanted to get all X where the value of Y can be or may not be null.我得到 X 的值,其中 Y 的值不为空。我想得到所有 X,其中 Y 的值可以是或不可以为空。

Any ideas as to how i can tweak the above query?关于如何调整上述查询的任何想法?

I'm not sure that this matters to you any more but to directly answer your question you need to deal with the chance that there are no "hasB" edges.我不确定这对您是否更重要,但要直接回答您的问题,您需要处理没有“hasB”边缘的可能性。 You might do that with coalesce() in the following fashion:您可以通过以下方式使用coalesce()做到这一点:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM