繁体   English   中英

当查询的一部分不返回任何内容时,Gremlin查询不返回任何结果

[英]Gremlin query is returning no results when part of the query returns nothing

我有一个gremlin查询,该查询找到我要存档的顶点,但它返回一个空数组。

我的图的布局方式是一个顶点可以有多个父级和子级。 存档顶点时,需要将其所有受影响的后代存档,这些后代将被此过程“孤立”。 如果任何后代具有返回中心顶点的路径,则不应将其归档,因为它不会被“孤立”

g.V(itemId)                                            // Find the item to delete.
  .union(                                              // Start a union to return
    g.V(itemId),                                       // both the item 
    g.V(itemId)                                        // and its descendants.
      .repeat(__.inE('memberOf').outV().store('x'))    // Find all of its descendants.
      .cap('x').unfold()                               // Unfold them.
      .where(repeat(out('memberOf')                    // Check each descendant
        .where(hasId(neq(itemId))).simplePath())       // to see if it has a path back that doesn't go through the original vertex
        .until(hasId(centralId)))                      // that ends at the central vertex .
      .aggregate('exception')                          // Aggregate these together.
      .select('x').unfold()                            // Get all the descendants again.
      .where(without('exception')))                    // Remove the exceptions.
  .property('deleted', true)                           // Set the deleted property.
  .valueMap(true)                                      // Rteurn the results.

当发现某些后代具有不经过原始顶点的返回中心顶点的路径时,它将起作用并返回所有应有的结果。 但是,如果找不到路径返回的任何后代,则理论上应该只返回所有后代。 相反,它返回一个空数组。 我的猜测是,在遍历的那个阶段之后它被卡住了,因为它什么也没发现,因此无法继续前进。

如果在那个阶段什么都没找到,我如何返回所有后代?

有关该图的示例,请参阅我之前的问题

更改行:

.select('x').unfold()

至:

.cap('x').unfold()

暂无
暂无

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

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