-
Notifications
You must be signed in to change notification settings - Fork 238
Troubleshooting
When working with Gremlin, there may be issues that arise. This section hopes to articulate common problems users have an how to resolve them.
The expression g.V[0]
seems like it is returning the first vertex in the graph. However, this statement is in fact creating an iterator/iterable (i.e. a Pipe) that will return the first vertex in the graph when next()
is called on it. Thus, use g.V[0]>>1
to return the first vertex in the graph. Better yes, just use g.V>>1
. The notation >>1
means “pop off the first object in the iterator and return it.”
Many times you will misplace a (
or a {
and your Gremlin terminal will be “stuck.” To get out of this situation, just type clear
to reset the parser.
gremlin> if(true) {
gremlin> 1+2
gremlin> {
gremlin> }
gremlin> 1
groovysh_parse: 24: Ambiguous expression could be a parameterless ...
1 error
gremlin> 1
groovysh_parse: 24: Ambiguous expression could be a parameterless ...
1 error
gremlin> clear
gremlin> 1
==>1
There is a single meta method added to Object
. This method is _
. The _
method denotes the IdentityPipe
. If all else fails in terms of trying to get an object to go through a pipe, use _
or _()
.