I have simple OrientDB query
MATCH {class:SomeObj, as:obj,
Where:(
(outE('SomeEdge')[in=#74:2].StringValue="STRINNNGGG") and
(outE('SomeEdge')[in=#75:2].NumberValue=333)
)
}
RETURN obj
The query returns one record in OrientDB Studio.
I am trying to execute the query in JAVA using Gremlin, but I did not succeed. I tried to execute these queries:
This query results in NoSuchElementException:
g.V().hasLabel("SomeObj").as("obj")
.where(
__.outE("'SomeEdge").inV().hasId("#74:2").has("StringValue", P.eq("STRINNNGGG"))
.and()
.outE("'SomeEdge").inV().hasId("#75:2").has("NumberValue", P.eq(333))
)
.select("obj")
.next();
The next query results in a ClassCastException in constructor of new AndP(), because str and number are not predicates.
GraphTraversal<Vertex, Vertex> str = __.outE("'SomeEdge").inV().hasId("#74:2").has("StringValue", P.eq("STRINNNGGG"));
GraphTraversal<Vertex, Vertex> number = __.outE("'SomeEdge").inV().hasId("#75:2").has("NumberValue", P.eq(333));
AndP andPredicate = new AndP(List.of(str, number));
g.V().hasLabel("SomeObject").as("obj")
.where(andP)
.select("obj").next();
How to rewrite above OrientDB query to Gremlin?
Also, I would like to see query which is built by Gremlin, but i didn't find a way
- To log all queries which is executed on OrientDB server Community Edition (analog
log_statement=ALLindata/postgresql.confof Postgres) - To log all queries on gremlin-server
- To print built query in java API, like example
g.V().hasLabel("SomeObject").toString()->select from SomeObject
I would appreciate it if you could tell me how to print query.
I figured out:
Hope it will help to someone.
But I didn't find out how to enable query logs on Orient or Gremlin server yet.