local
Limit the operation of the traversal to a single element within the traversal.
Synopsis
local(traversal)
Description
The local()
step is a branch step that allows the action within the step to be applied to the element within the local()
step.
Examples
Get a list of all people and the countries they have lived in, ordered by the year that the person started living in the country:
g.V().hasLabel('person').as('person'). local(properties('country').order().by('startYear', incr).limit(2)).value().as('country'). select('person','country'). by('name').by()
Here, local()
is used to restrict the sorting by the meta-property startYear for each person.
g.V().has('person','personId','1').local(outE('created').has('createDate', gte('1962-03-03')).order().by('createDate'))
// explain //g.V().hasLabel('person').outE('reviewed').has('stars', gte(1)).order().by('stars').profile() // Sorts the reviews by stars for each user - uses the edge index //g.V().hasLabel('person').local(outE('reviewed').has('stars', gte(1)).order().by('stars')).profile() // Sorts the users by name, and then their reviews by stars //g.V().hasLabel('person').order().by('name').local(outE('reviewed').has('stars', gte(1)).order().by('stars')).profile()