使用上一个边缘的值

时间:2018-03-14 00:04:10

标签: python gremlin amazon-neptune

我在OSX上使用最新的pip上的Gremlin Python,用于在AWS Neptune上托管的数据库。
我想使用先前遍历的边缘的值 例子优于10行解释。

g.V(2).outE().values('stop_timestamp').store('stop_ts').inV().outE().where(has('start_ts', between('stop_ts', end_ts)))

我想使用stop_ts值(只是Int)并在between语句中使用它。
目前我只有错误:

gremlin_python.driver.protocol.GremlinServerError: 597: Exception processing a script on request

我认为不可能使用先前遍历的边缘值,这将是一种耻辱,但我需要确认。

编辑:似乎是neq& eq不会崩溃,但不会betweengtelte(因为between只会转换为gte和{{1} }})

1 个答案:

答案 0 :(得分:3)

我会尝试为您提出一个查询,但是为了开始,我假设您已经看过这个文档,它解释了每个谓词可以接受的类型:

http://tinkerpop.apache.org/docs/current/reference/#a-note-on-predicates

有些事情也可能有所帮助。以下模式是有效的,我认为可以适用于您的情况。我从Gremlin控制台测试了它们。您可能需要调整一些东西才能让它们在Gremlin Python中运行,但这些Gremlin模式都是比较事物的有效方法。

// Compares two elements with a common property
// Assumes 'a' and 'b' are references to earlier parts of the query.
where('a',gt('b')).by('timestamp')

// References an external variable
// Assumes timestamp is a property of the prior traversal step
where(values('timestamp').is(gt(x)))

// If you need to select a previously labeled step and compare
// you can do this
where(select('timestamp').is(gt(x)))
相关问题