简体   繁体   English

将Neo4j密码查询转换为OrientDB / Gremlin(在Java中)

[英]Translating a Neo4j cypher query into orientdb / gremlin (in java)

I have a Neo4j cypher query that looks like this: 我有一个Neo4j密码查询,如下所示:

MATCH (b:VertexType1)-[e1]-(a:VertexType2)-[e2]-(c:VertexType1)-[e3]-(d) 匹配(b:VertexType1)-[e1]-(a:VertexType2)-[e2]-(c:VertexType1)-[e3]-(d)

What this translates to in english (I think) is: 我想这翻译成英文是:

"Find me a chain of vertices 'b','a','c','d' of type 'VertexType1', 'VertexType2', 'VertexType1' and 'VertexTypeAny' in that order connected by any kind of edges 'e1','e2' and 'e3'" 按顺序为我找到由'VertexType1','VertexType2','VertexType1'和'VertexTypeAny'类型的顶点'b','a','c','d'组成的一系列顶点,并通过任何类型的边'e1 ','e2'和'e3'”

What's the equivalent of this using OrientDB and gremlin in java? 在Java中使用OrientDB和gremlin等效于什么?

It seems like if I would want to start with : 似乎如果我想开始:

for(Vertex a : orientGraph.getVerticesOfClass("VertexType2")){

}

and then start my gremlin code with vertex 'a' followed by a 'both' so that I spread out from vertex 'a' until I confirm / deny that a is connected in the way that I want. 然后从顶点“ a”开始我的格雷姆林代码,然后是“两者”,以便我从顶点“ a”展开,直到确认/拒绝a以我想要的方式连接。

In the end I want to have all the vertices and edges in Java so that I can do some adding / removing of edges and vertices, so I'd have: 最后,我想拥有Java中的所有顶点和边,以便可以添加/删除边和顶点,因此我需要:

OrientVertex a;
OrientVertex b;
OrientVertex c;
OrientVertex d;
OrientEdge e1;
OrientEdge e2;
OrientEdge e3;

Is this possible with gremlin in java? Java中的gremlin是否可能?

这是您要查找的gremlin查询:

 g.V().has('@class', T.eq, 'VertexType1').as('b').bothE().as('e1').bothV().as('a').has('@class', T.eq, 'VertexType2').bothE().as('e2').bothV().as('c').has('@class', T.eq, 'VertexType1').bothE().as('e3').bothV().path

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

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