OrientDB create edge issue in batch/script

不羁岁月 提交于 2019-12-11 12:40:10

问题


I have 2 problems with edge creation.

First, I'm creating a bunch of vertices and edges with a batch command. Sometimes and edge is created between vertices that havent been created yet (it depends on the input order, and for now that cannot be controlled). Of course Orient server throws an exception instead of failing silently. I couldnt find a way of telling it to skip it or avoid creating the edge. In Neo4j you can do:

MATCH (a {id:'zz'}),(b {id:'yy'})
CRAETE UNIQUE (a)-[r:REL {'id': 'xx'}]->(b)

So if a or b don't exist, no edge is created.

Is there a way to do something like that? Doing a select before to check for existence of both a and b is no good because the vertex could be created in the previous batch command, thus not present in the db, so it has to be part of the osql command.

Second, related to this issue, I was thinking i could build a script so I could assign the select that looks for both a and b to a variable.

BEGIN
LET source = SELECT FROM V WHERE id = 'zz'
LET target = SELECT FROM V WHERE id = 'yy'
<< some sort of condition based on source != null and target != null? >>
LET edge = CREATE EDGE REL FROM $source TO $target
COMMIT

Is it possible to issue the creation command base on a condition on both source and target?. If so, that would solve both issues.


回答1:


it will be available since v. 2.1.7

https://github.com/orientechnologies/orientdb-docs/blob/master/SQL-batch.md#conditional-execution



来源:https://stackoverflow.com/questions/34029088/orientdb-create-edge-issue-in-batch-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!