I have a Neo4j cypher query that looks like this:
MATCH (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'"
What's the equivalent of this using OrientDB and gremlin in java?
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.
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:
OrientVertex a;
OrientVertex b;
OrientVertex c;
OrientVertex d;
OrientEdge e1;
OrientEdge e2;
OrientEdge e3;
Is this possible with gremlin in java?
This is the gremlin query you are looking for:
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