1
votes

I am using janusgraph to develop my java backend. I want to prepare my query on the elements regardless being edges or vertices before specifying to query edges or vertices this will give me flexibility in my code when it comes to building the query dynamically on the properties.

So my question is,Can I use gremlin to prepare the query before starting from V or E ?

For example if I want to apply the same query to Edges and vertices I will write:

g.V().has("p1","v1").has("p2","v1").has("p3","v1")
g.E().has("p1","v1").has("p2","v1").has("p3","v1")

What I am seeking for is something like this

gt = grahTraversal.has("p1","v1").has("p2","v1").has("p3","v1")
gt.E()
gt.V()

Thanks

1

1 Answers

1
votes

You can use the code like this(JAVA)

import static org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__.*;

...

GraphTraversal g = __.has("p1","v1").has("p2","v1").has("p3","v1");
resultG = grahTraversal.E().where(g);
resultG = grahTraversal.V().where(g);

The details can be found in official documents .