我试图使用coalesce对插入边进行批处理。我试图遵循在Neptune DB文档上找到的批处理边缘插入的格式
g.V('v-1')
.outE('KNOWS')
.hasId('e-1')
.fold()
.coalesce(unfold(),
V('v-1').addE('KNOWS')
.to(V('v-2'))
.property(id, 'e-1'))
.V('v-3')
.outE('KNOWS')
.hasId('e-2').fold()
.coalesce(unfold(),
V('v-3').addE('KNOWS')
.to(V('v-4'))
.property(id, 'e-2'))
.V('v-5')
.outE('KNOWS')
.hasId('e-3')
.fold()
.coalesce(unfold(),
V('v-5').addE('KNOWS')
.to(V('v-6'))
.property(id, 'e-3'))
.next()当我在我的Python中使用这种格式时,我得到了name 'V' is not defined的错误。我知道Gremlin Python与Gremlin语言略有不同。但我找不到这方面的文件。
我试着在V前面加上双下划线,如下所示:
g.V('v-1')
.outE('KNOWS')
.hasId('e-1')
.fold()
.coalesce(unfold(),
__.V('v-1').addE('KNOWS')
.to(__.V('v-2'))
.property(id, 'e-1'))
...
.next()但是我得到了一个错误Received error message '{'requestId': 'None', 'status': {'code': 499, 'message': '{"detailedMessage":"Invalid OpProcessor requested [null]","code":"UnsupportedOperationException"}', 'attributes': {}}, 'result': {'meta': {}, 'data': None}}'
我会像这样和绿毛毛虫联系:
def get_connection(endpoint):
return DriverRemoteConnection(endpoint, 'g')
def get_graph(connection):
return traversal().withRemote(connection)
connex = get_connection(neptune_endpoint)
g = get_graph(connex)编辑解决方案是使用__.V而不是V,并将id改为T.id。谢谢你的帮助和及时的回应!
发布于 2022-11-10 21:43:17
在使用Python客户端处理保留字冲突和其他问题时,有几点是不同的。正如您注意到的,匿名遍历(嵌套在另一次遍历中的遍历)需要使用“双下划线”表示法,如__.V('1')中的那样。
类似地,Python中有几个内置函数与Gremlin名称发生冲突。id就是其中之一。要解决这个问题,只需指定T.id即可。
https://stackoverflow.com/questions/74395300
复制相似问题