dongwupu5991 2019-04-09 19:14
浏览 169
已采纳

AQL更新在收集循环中成功,但是在图形遍历中引发未找到的错误

I am trying to figure out how to update edge documents using a graph traversal query in arangodb. I am able to do this using the standard FOR e IN collectionName UPDATE e with {newProps} IN collectionName. However I cannot figure out what is wrong with my attempt to accomplish the same thing using the FOR v, e, p IN 1..5 OUTBOUND @startId GRAPH @graphName syntax.

I am using the arangodb:latest docker image on macOS Mojave 10.14.3, and I am using arango's go library (github.com/arangodb/go-driver) to query by building a query string and sending it using the Database.Query() function. I have tried just returning the key for the edge I'm trying to update (i.e. just returning e._key instead of attempting to update in the query below), and have verified using arangosh that that is indeed the correct key of the edge I'm trying to update. Additionally as stated above, I have been able to update an edge using the relational AQL syntax.

Here is my query:

FOR v, e, p IN 1..5 OUTBOUND @startId GRAPH @graphName
    FILTER e.@key0 == @val0
    UPDATE e._key WITH {@propName0: @propValue0} IN has_skill
    RETURN {new: NEW, old: OLD}

and here are my bind variables:

[graphName:Matthew_Loughney, key0:_from, propName0:testProp, propValue0:testVal, startId:applicant/232, val0:applicant/232]

I would expect that when I view the has_skill collection using arangosh, I would see that my edge now has a property testProp with value testVal; however, I instead just get the error AQL: document not found (while executing) and my edge remains unchanged.

  • 写回答

1条回答 默认 最新

  • douou6696 2019-04-09 20:19
    关注

    It turned out that my filter was returning some edges not in the has_skill collection (4 total to be exact), so when it tried to update in has_skill, it succeeded for the one I wanted but failed for the other 3, and since the UPDATE operation is atomic that made it fail for all of them. I did not notice this because I was only looking at the first edge returned when looking at the keys, and this wasn't an issue in my FOR e IN collectionName query because obviously those are all in the correct collection, so that only returned the 1 edge I was looking for.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 解决websocket跟c#客户端通信
  • ¥30 Python调用dll文件输出Nan重置dll状态
  • ¥15 浮动div的高度控制问题。
  • ¥66 换电脑后应用程序报错
  • ¥50 array数据同步问题
  • ¥15 pic16F877a单片机的外部触发中断程序仿真失效
  • ¥15 Matlab插值拟合差分微分规划图论
  • ¥15 keil5 target not created
  • ¥15 C/C++数据与算法请教
  • ¥15 怎么找志同道合的伙伴