gremlin顺序与凝聚重复一些值

时间:2018-11-26 13:21:30

标签: gremlin tinkerpop

在某些情况下,当我将order().by(...)coalesce(...)一起使用时,会得到莫名其妙的结果。 使用标准的现代图形,

gremlin> g.V()
          .hasLabel("person")
          .out("created")
          .coalesce(values("name"), constant("x"))
          .fold()
==>[lop,lop,ripple,lop]

但是,如果我在合并之前按名称排序,则会得到9 lop而不是3:

gremlin> g.V()
          .hasLabel("person")
          .out("created")
          .order().by("name")
          .coalesce(values("name"), constant("x"))
          .fold()
==>[lop,lop,lop,lop,lop,lop,lop,lop,lop,ripple]

为什么两个查询之间的元素数不同?

1 个答案:

答案 0 :(得分:1)

这看起来像个错误-我创建了一个issue in JIRA。有一种解决方法,但首先考虑到即使保留了错误,遍历也不会真正起作用,order()将失败,因为您引用的是{{1}中可能不存在的键调制器。因此,您需要以不同的方式考虑:

by()

然后我用g.V(). hasLabel("person"). out("created"). order().by(coalesce(values('name'),constant('x'))) 来完成choose()应该做的事情:

coalesce()

这似乎很好。

相关问题