简体   繁体   English

如何在 Tinkerpop (OrientDB) gremlin 查询中删除子图?

[英]How to drop a subgraph in Tinkerpop (OrientDB) gremlin query?

Requirement is to drop this subgraph if I have runId and appId .如果我有runIdappId ,要求是删除这个子图。 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.我尝试了以下查询来删除子图,但只有IOappRun被删除。 The iRecord & oRecord don't get dropped. iRecordoRecord不会被丢弃。 Is this because I loose the gremlin pointer?这是因为我失去了 gremlin 指针吗? So question is how to delete the iRecord and oRecord .所以问题是如何删除iRecordoRecord

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 .但这将删除oRecordaRunio而不是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.

相关问题 如何在 Java 中使用 Gremlin/Tinkerpop? - How do I use Gremlin/Tinkerpop with Java? 如何将Gremlin Tinkerpop Vertex转换为POJO - How to transform Gremlin Tinkerpop Vertex to a POJO 如何使用Gremlin和Java查询远程Apache Tinkerpop图形数据库? - How can I query a remote Apache Tinkerpop Graph Database with Gremlin and Java? tinkerpop gremlin 中是否存在错误的 function? - Is there a false function in tinkerpop gremlin? 如何通过OrientDB中的Graph API(Tinkerpop Blueprints)按边检索顶点? - How to retrieve vertexes by edges by Graph API (Tinkerpop Blueprints) in OrientDB? 如何以tinkerpop / gremlin格式而不是DSE图形格式返回Vertex? - How to return a Vertex in the tinkerpop/gremlin format instead of the DSE graph format? 如何使用来自 tinkerpop/gremlin 的底层资源从 simplegraph 制作 JAR - How to make a JAR from simplegraph with underlying sources from tinkerpop/gremlin TinkerPop Gremlin How to serealize Predicate 传入直到步骤 - TinkerPop Gremlin How to serealize Predicate passed in Until step 删除 Netpune Gremlin 会话查询 - Drop in Netpune Gremlin Session Query 如何从gremlin返回子图,它是Java的易用格式 - how to return subgraph from gremlin that is in an easily consumable format for Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM