![](/img/trans.png)
[英]Gremlin - Best way to select properties from multiple vertices in single query
[英]Gremlin select multiple vertices gives an output without the properties with null values
為了從兩個頂點 a 和 bi 獲取所有數據,使用以下命令
g.V('xxx').out('hasA')..as('X').out('hasB').as('Y').select('X','Y').
我得到 X 的值,其中 Y 的值不為空。我想得到所有 X,其中 Y 的值可以是或不可以為空。
關於如何調整上述查詢的任何想法?
我不確定這對您是否更重要,但要直接回答您的問題,您需要處理沒有“hasB”邊緣的可能性。 您可以通過以下方式使用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.