emit

Emit traversers before or after a repeat() step.

Synopsis

emit( [ 'predicate' | 'traversal' ])
Table 1. Legend
Syntax conventions Description
Lowercase and uppercase Literal keyword. Includes ().
Italics Variable value. Replace with a user-defined value.
[] Optional. Square brackets ( [] ) surround optional command arguments. Do not type the square brackets.
{} Group. Braces ( {} ) identify a group to choose from. Do not type the braces.
| Or. A vertical bar ( | ) separates alternative elements. Type any one of the elements. Do not type the vertical bar.
... Repeatable. An ellipsis ( ... ) indicates that you can repeat the syntax element as often as required.

Description

The emit() step is a step modulator, a helper step for another traversal step. Its main use is to emit either incoming traversers before a repeat() step, or emit outgoing traversers after a repeat() step. The emission sends a copy of the current objects to the next step in the query. A predicate or traversal can be used in an emit() step to cause the emission only if the predicate or traversal is true.

Examples

g.V(1).emit().repeat(out()).times(2).path()
==>[v[1]]
==>[v[1],v[3]]
==>[v[1],v[2]]
==>[v[1],v[4]]
==>[v[1],v[4],v[5]]
==>[v[1],v[4],v[3]]
gremlin> g.V(1).repeat(out()).times(2).emit().path()
==>[v[1],v[3]]
==>[v[1],v[2]]
==>[v[1],v[4]]
==>[v[1],v[4],v[5]]
==>[v[1],v[4],v[3]]