【问题标题】:Use value from previous edge使用前一个边的值
【发布时间】:2018-03-14 00:04:10
【问题描述】:

我正在使用 Gremlin Python,最新版本在 pip,在 OSX 上用于 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 只是翻译成gtelte

【问题讨论】:

    标签: python gremlin amazon-neptune


    【解决方案1】:

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

    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)))
    

    【讨论】:

    • 感谢您的帮助开尔文。第一个给我gremlin_python.driver.protocol.GremlinServerError: 599: null:where([arr, gt(1520166000)]) 第二个给我TypeError: 'Column' object is not callable:/
    • 看来where(select('timestamp').is(gt(x))) 有效!谢谢@Kelvin
    猜你喜欢
    • 2012-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 2022-07-22
    • 1970-01-01
    • 2017-12-31
    相关资源
    最近更新 更多