How can I run multiple Gremlin statements in OrientDb?

125 views
Skip to first unread message

Valery T

unread,
Sep 14, 2015, 10:53:36 AM9/14/15
to OrientDB
I have multiple Gremlin addVertex/addEdge statements.
How can I run them in OrientDb?

Jan Plaček

unread,
Sep 14, 2015, 11:09:25 AM9/14/15
to OrientDB
It' about creating a pipe or compiling a query/statement into a pipe and passing graph instance to that pipe.
You can also run scripts containing queries via interpreter.
Detailed info here:


Dne pondělí 14. září 2015 16:53:36 UTC+2 Valery T napsal(a):

Valery T

unread,
Sep 14, 2015, 11:23:23 AM9/14/15
to OrientDB
I would like to run them from a console or Studio, not from Java code.

Jan Plaček

unread,
Sep 14, 2015, 4:17:01 PM9/14/15
to OrientDB
I think you actually want to run a script which uses Gremlin API, afaik it's not possible with Studio.
The Studio does not work as (groovy) script interpreter, it only takes the input and tries to convert that input into a Pipe and than execute that Pipe on a graph.
However the pipes are very powerful - you can execute basically any kind of script logic in the pipe's side effect, so for example you can do this:

g.addVector("class:Test").sideEffect{g.addVector("class:Test")}

It will add two verticies of type Test, however it's not very readable.
You should do some reading about what Gremlin actually is and how it works. The important is a concept of Pipe.
The Gremlin query itself is just a representation of a Pipe written in sripting language (Groovy).
That representation might look totally alien to you, but it's because of some fancy features the Groovy languages offers, like optional parenthesis, closures, metaprogramming and so on.

Dne pondělí 14. září 2015 17:23:23 UTC+2 Valery T napsal(a):

Valery T

unread,
Sep 14, 2015, 5:03:57 PM9/14/15
to orient-...@googlegroups.com
I discovered that I can run multiple Gremlin addVertex/addEdge statements in Gremlin console, which is shipped with the OrientDb Enterprise 2.1.0. 

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/VhXzpwYOp00/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jan Plaček

unread,
Sep 14, 2015, 5:31:36 PM9/14/15
to OrientDB
yea, because gremlin console is actually Groovy interpreter with included dependencies to Gremlin API

Dne pondělí 14. září 2015 23:03:57 UTC+2 Valery T napsal(a):

Valery T

unread,
Sep 15, 2015, 10:45:15 AM9/15/15
to orient-...@googlegroups.com
I can run Gremlin statements in Studio:
g.addVertex()
Reply all
Reply to author
Forward
0 new messages