简体   繁体   English

AQL更新在集合循环中成功,但在图遍历中抛出未找到的错误

[英]AQL update succeeds in collection loop but throws not found error in graph traversal

I am trying to figure out how to update edge documents using a graph traversal query in arangodb. 我试图找出如何使用arangodb中的图遍历查询更新边文档。 I am able to do this using the standard FOR e IN collectionName UPDATE e with {newProps} IN collectionName . 我可以使用标准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. 但是,我无法弄清楚我尝试使用FOR v, e, p IN 1..5 OUTBOUND @startId GRAPH @graphName语法完成同样的事情有什么问题。

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. 我在macOS Mojave 10.14.3上使用arangodb:最新的docker镜像,我使用arango的go库(github.com/arangodb/go-driver)通过构建查询字符串并使用Database.Query发送它来进行查询( )功能。 I have tried just returning the key for the edge I'm trying to update (ie 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. 我已经尝试只返回我正在尝试更新的边缘的密钥(即只返回e._key而不是尝试在下面的查询中更新),并且已经使用arangosh验证这确实是边缘的正确密钥我我试图更新。 Additionally as stated above, I have been able to update an edge using the relational AQL syntax. 另外,如上所述,我已经能够使用关系AQL语法更新边缘。

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 ; 我希望当我使用arangosh查看has_skill集合时,我会看到我的边缘现在有一个属性testProp ,其值为testVal ; however, I instead just get the error AQL: document not found (while executing) and my edge remains unchanged. 但是,我只是得到错误AQL: document not found (while executing) ,我的边缘保持不变。

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. 事实证明,我的过滤器返回了一些不在has_skill集合中的边缘(总共4个),所以当它尝试在has_skill更新时,它成功用于我想要的那个但是对其他3个失败了,并且因为UPDATE操作是原子的,使它失败了所有这些。 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. 我没有注意到这一点,因为我只是看着看到键时返回的第一条边,这在我的FOR e IN collectionName查询中不是问题,因为显然这些都在正确的集合中,所以只返回了我正在寻找1条边缘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM