-
Notifications
You must be signed in to change notification settings - Fork 116
Rexster Console
Rexster Console is a REPL similar to the REPL available from Gremlin. It differs in several ways:
- Script evaluation within Rexster Console occurs remotely on a Rexster server.
- Rexster Console communicates with any JSR223 compliant ScriptEngine hosted within the Rexster server. The variable pool is shared across each engine. In this way, its possible to make use of each language’s unique expressive qualities when manipulating variables.
- Rexster Console provides access to configured graphs within Rexster server through the
rexster
variable that is injected into the variable pool on the server.
To start the console, first ensure that the Rexster server is running. Then start the console from the command line:
rexster-console.sh
(l_(l
(_______( 0 0
( (-Y-) <woof>
l l-----l l
l l,, l l,,
opening session with Rexster [localhost:8185]--> ready
?h for help
rexster[gremlin]>
Note the language name in square brackets. This represents the script engine language that the line will be evaluated with on the server. It’s easy to see what languages are available on the server:
rexster[gremlin]> ?l
-= Available Languages =-
?ECMAScript
?gremlin
?Groovy
To change languages simply type one of those languages (case sensitive) into the command-line:
rexster[gremlin]> ?Groovy
rexster[Groovy]>
Variables are shared across script engines within a Rexster Console session.
rexster[gremlin]> x = 1 + 1
==>2
rexster[gremlin]> ?Groovy
rexster[Groovy]> x = x + 1
==>3
rexster[Groovy]> ?ECMAScript
rexster[ECMAScript]> y = x + 1
==>4.0
rexster[ECMAScript]> ?gremlin
rexster[gremlin]> x + y
==>7.0
Getting access to graphs configured within Rexster is allowed through the rexster
variable which is a context object on the server.
rexster[gremlin]> g = rexster.getGraph("tinkergraph")
==>tinkergraph[vertices:6 edges:6]
rexster[gremlin]> g.v(1).name
==>marko
The Rexster Console requires three parameters for startup: host, port and start language. By default these are set as follows:
rexster-console.sh localhost 8185 gremlin
Port 8185 is the default RexPro port as defined in rexster.xml
. Please see the Rexster Configuration section for more information on this setting.