I am fairly new to gremlin query and janusgraph. I had a requirement to get both edges and nodes of the graph given various properties of the nodes and the relationship between them. There can be multiple properties and/or relationships and a logical operator between them.
After a good amount of research and going through PRACTICAL GREMLIN: An Apache Tinkerpop Tutorial I figured a way to do this in a single query., i.e, using path() step.
For example a simple query with one property or relationship filter would look like this:
g.V().hasLabel("label").has("prop1", eq("prop1-value").path().toList()
g.V().hasLabel("label").outE("relation1").inV().hasLabel("related_node").path().toList()
Such queries worked fine, where the result contained both edges and nodes whenever there is a relationship involved in the query.
However, for complex queries where multiple relationships or combination of relationship and properties are involved, the query doesnt return edges. It only returns nodes. For example:
g.V().hasLabel("label").and(has("prop1", eq("prop1-value"), outE("relation1").inV().hasLabel("related_node")).path().toList()
g.V().hasLabel("label").or(has("prop1", eq("prop1-value"), outE("relation1").inV().hasLabel("related_node")).path().toList()
g.V().hasLabel("label").or(inE("relation2").outV().hasLabel("another_node"), outE("relation1").inV().hasLabel("related_node")).path().toList()
Why doesnt the path() step doesnt include the edges in such cases mentioned above? Any help is much appreciated.
Note: The gremlin query is constructed in Java using gremlin-java.
I have also tried to use select step which didn't help.