I'm using Gremlin Python, latest available on pip
, on OSX for a DB hosted on AWS Neptune.
I would like to use a value from a previously traversed edge.
Example is better than 10 lines of explanation.
g.V(2).outE().values('stop_timestamp').store('stop_ts').inV().outE().where(has('start_ts', between('stop_ts', end_ts)))
I would like to use the stop_ts
value (just an Int
) and use it inside the between
statement.
Currently I only have error like:
gremlin_python.driver.protocol.GremlinServerError: 597: Exception processing a script on request
I think it's not possible to use a value from a previously traversed edge, would be a shame but I would need a confirmation.
EDIT: It seems that neq
& eq
doesn't crash but not between
, gte
, lte
(as between
is just translated to gte
and lte
)
I will try coming up with a query for you but to get started I assume you have seen this documentation which explains what types each of the predicates can accept:
http://tinkerpop.apache.org/docs/current/reference/#a-note-on-predicates
A couple of things that may also help. The following patterns are valid and I think can be applied in your case. I tested them both from the Gremlin Console. You may need to tweak things to get them working in Gremlin Python but these Gremlin patterns are both valid ways to compare things.
// 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)))