【问题标题】:Add an edge failing after creating a vertex (Neptune InternalFailureException)创建顶点后添加失败的边 (Neptune InternalFailureException)
【发布时间】:2021-08-04 05:41:36
【问题描述】:

我正在尝试创建一个用户顶点和一个城市顶点(如果它们在图中尚不存在),然后在它们两者之间添加一条边。当我在同一次遍历中执行命令时,我从 Neptune 遇到了这个 InternalFailureException

g.V("user12345").
fold().
coalesce(unfold(),addV("user").property(id, "user-12345")).as('user').
V("city-ATL").
fold().
coalesce(unfold(), addV("city").property(id, "city-ATL")).as("city").
addE("lives_in").
  from("user").
  to("city")

{"code":"InternalFailureException","detailedMessage":"An unexpected error has occurred in Neptune.","requestId":"xxx"}

(请注意,在上例中,user-12345city-ATL 都不存在于图中)。

但是,当我在执行命令之前创建城市时,它工作得很好:

 gremlin> g.V("city-ATL").
          fold().
          coalesce(unfold(),       
                   addV("city").property(id, "city-ATL"))
 ==>v[city-ATL]

 gremlin> g.V("user-12345").
          fold().
          coalesce(unfold(),addV("user").property(id, "user-12345")).as('user').
          V("city-ATL").
          fold().
          coalesce(unfold(), addV("city").property(id, "city-ATL")).as("city").
          addE("lives_in").from("user").to("city")

 ==>e[1abd87d6-6f54-9e42-ae0a-47401c9dcfe6][user-12345-lives_in-city-ATL]

我正在尝试构建一个可以同时完成它们的遍历。有谁知道为什么海王星会在城市不存在的情况下抛出这个InternalFailureException

【问题讨论】:

    标签: gremlin amazon-neptune


    【解决方案1】:

    我将进一步调查为什么您没有收到更有用的错误消息,但我可以看到 Gremlin 查询需要更改。在fold 步骤之后,任何先前的as 标签都将丢失,因为fold 将遍历器减少到一个。 fold 既是屏障又是地图。您应该能够使用storeaggregate(local) 而不是as,在这种情况下,您必须为每个coalesce 使用fold

    gremlin> g.V('user-1234').
    ......1>   fold().
    ......2>   coalesce(unfold(),addV('person').property(id,'user-1234')).store('a').
    ......3>   V('city-ATL').
    ......4>   fold().
    ......5>   coalesce(unfold(),addV('city').property(id,'city-ATL')).store('b').
    ......6>   addE('lives_in').
    ......7>     from(select('a').unfold()).
    ......8>     to(select('b').unfold())  
    
    ==>e[0][user-1234-lives_in->city-ATL]  
    

    【讨论】:

    • 在折叠 V().has('Label1', 'name', 'vertex1') 并在合并中展开后,我看到了同样的错误。我只是将 V()... 移到了 coalesce 中,它可以工作。感谢您指出此神秘错误消息的原因!
    猜你喜欢
    • 1970-01-01
    • 2013-02-07
    • 1970-01-01
    • 2020-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-18
    • 1970-01-01
    相关资源
    最近更新 更多