Gremlin with Neptune:使用具有先前边缘值的数学结果过滤边缘

Gremlin with Neptune: filter edges using math result with previous edge value

我有下图:

而我想解决如下遍历:

  1. 从节点“abc-01-05”开始
  2. 转到主“ip”节点(id:abc)
  3. 从ip节点开始遍历出边,其中日期“at_millis”小于第2步+1天遍历的边
  4. 结果应该是节点:abc-01-05 和 abc-02-05

我能做出的最佳查询是基于 ,但不起作用:

g.V('abc-01-05')
    .outE('related_to').as_('saved_edge')
    .inV()
    .inE('related_to')
    .where(
        P.lte('saved_edge')
    )
    .by('at_millis')
    .by(__.math('saved_edge + 86400001').by('at_millis'))
    .toList()

这个returns这个错误:

GremlinServerError: 500: {"requestId":"3aaaca37-75eb-4650-b111-130c6e65b040","code":"InternalFailureException","detailedMessage":"Exception processing a script on request [RequestMessage{, requestId=3aaaca37-75eb-4650-b111-130c6e65b040, op='bytecode', processor='traversal', args={gremlin=[[], [V(abc-01-05), outE(related_to), as(saved_edge), inV(), inE(related_to), where(lte(saved_edge)), by(at_millis), by([[], [math(saved_edge + 86400001), by(at_millis)]])]], aliases={g=g}}}]."}

任何帮助都会很有帮助!谢谢!

一种方法:

g.V('abc-01-05').
  outE('related_to').as('saved_edges').
  values('at_millis').as('a1').
  math('a1 + 86400001').as('saved_edges_millis_plus_1_day').
  select('saved_edges').
  inV().
  inE('related_to').as('intermediate_edges').
  values('at_millis').
  where(P.lt('saved_edges_millis_plus_1_day')).
  select('intermediate_edges')

添加另一个答案只是为了指出您在原始查询中看到的错误是因为 by 步骤需要撤消。第二个 by 调制器在 where 步骤中应用于标签。第一个 by 调制器定义了它将与什么进行比较。此外,要使测试正常运行,需要对被测试的值进行细微调整。这是原始查询的工作版本。

g.V('abc-01-05')
    .outE('related_to').as('saved_edge')
    .inV()
    .inE('related_to').as('related')
    .where(P.lte('related'))
      .by(__.math('saved_edge + 86400000').by('at_millis'))
      .by('at_millis')