graph
graph copied to clipboard
Add an example of using nested select steps to select derived keys from an injected map
gremlin> temps = [Atlanta:66.2,Austin:70.9,Anchorage:42.6,Seattle:54.1]
==>Atlanta=66.2
==>Austin=70.9
==>Anchorage=42.6
==>Seattle=54.1
gremlin> g.withSideEffect('t',temps).V().
......1> has('city',within('Austin','Atlanta','Anchorage','Seattle')).
......2> values('city').as('c').
......3> project('Location','2019-Avg-Temp').
......4> by().
......5> by(select('t').select(select('c')))
==>[Location:Atlanta,2019-Avg-Temp:66.2]
==>[Location:Anchorage,2019-Avg-Temp:42.6]
==>[Location:Austin,2019-Avg-Temp:70.9]
==>[Location:Seattle,2019-Avg-Temp:54.1]
This discussion probably would fit well right after section 3.23 where the inject() step is introduced.
Could further show that inject can be used with an as step to achieve the same result:
g.inject([Atlanta:66.2,Austin:70.9,Anchorage:42.6,Seattle:54.1]).as('t').
V().
has('city',within('Austin','Atlanta','Anchorage','Seattle')).
values('city').as('c').
project('Location','2019-Avg-Temp').
by().
by(select('t').select(select('c')))