[英]How to drop a subgraph in Tinkerpop (OrientDB) gremlin query?
Requirement is to drop this subgraph if I have runId
and appId
.如果我有
runId
和appId
,要求是删除这个子图。 Application can have multiple such appId and thus should be deleted only if no appId
is attached to it.应用程序可以有多个这样的 appId,因此只有在没有附加
appId
时才应将其删除。
I have tried the below query to drop the subgraph, but only IO
and appRun
gets dropped.我尝试了以下查询来删除子图,但只有
IO
和appRun
被删除。 The iRecord
& oRecord
don't get dropped. iRecord
和oRecord
不会被丢弃。 Is this because I loose the gremlin pointer?这是因为我失去了 gremlin 指针吗? So question is how to delete the
iRecord
and oRecord
.所以问题是如何删除
iRecord
和oRecord
。
I was planning to delete the appId
in second traversal call.我打算在第二次遍历调用中删除
appId
。 So can I check if the appId
has no more connected runId
and drop appId
in the same traversal.那么我可以检查
appId
是否没有更多连接的runId
并在同一次遍历中删除appId
。
db.getTraversal()
.V().has("aRun", "runId", runId).as("aRun")
.outE("hasIO")
.inV().hasLabel("io").as("io")
.sideEffect(outE("output").inV().has("oRecord").drop())
.sideEffect(inE("input").outV().has("iRecord").drop())
.sideEffect(select("aRun").drop())
.sideEffect(select("io").drop())
.iterate();
I also tried version of answer provided here: Link我还尝试了此处提供的答案版本: 链接
db.getTraversal().
V().has("aRun", "runId", runId)
emit().
repeat(out()).
fold().
unfold().
drop()
But this will delete the oRecord
, aRun
and io
but not the iRecord
.但这将删除
oRecord
、 aRun
和io
而不是iRecord
。 And question of how to drop appId
remains.如何删除
appId
的问题仍然存在。
Thanks谢谢
pom.xml: pom.xml:
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-gremlin</artifactId>
<version>3.0.25</version>
</dependency>
I used this query:我使用了这个查询:
db.getTraversal()
.V().has("app", "appId", appId).as("app")
.outE("hasRun")
.inV().has("aRun", "runId", runId).as("aRun")
.outE("hasIO")
.inV().hasLabel("io").as("io")
.sideEffect(outE("output").inV().hasLabel("oRecord").drop())
.sideEffect(inE("input").outV().hasLabel("iRecord").drop())
.sideEffect(select("app").filter(outE("hasRun").count().is(1)).drop())
.sideEffect(select("aRun").drop())
.sideEffect(select("io").drop())
.iterate();
Thanks!谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.