问题
I have a Gremlin query in the String format (for example "g.V()"). I want to execute this String without submitting it to the GremlinServer.
I use the below dependency:
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-driver</artifactId>
<version>3.3.1</version>
</dependency>
Is there any way?
回答1:
You can execute Gremlin string directly in GremlinGroovyScriptEngine or through the GremlinExecutor (which just passes the string to the GremlinGroovyScriptEngine
but has some additional features to it). Simple pass the Gremlin string to the appropriate eval()
method and get back a result from that script evaluation. That's basically what Gremlin Server does internally.
You will likely need the gremlin-groovy
dependency rather than gremlin-driver
.
来源:https://stackoverflow.com/questions/50254378/get-gremlin-query-as-a-string-and-execute-it-in-java-without-submitting-it-to-th