Is there any way to return data from gremlin in the form of hashmap?

I want to know whether I can get data from Gremlin query in the form of HashMap(One vertex as key and another as value).

g.V().has('familyName','Smith').as('familyName').out().as('name').select('familyName','name').by('property1').by('property2')

The above queries retrieves the result as :

{
'familyName:Smith'
'name:John'
}

I want the result to be

{
'Smith:John'
}

Upvotes: 0

Views: 223

Answers (1)

stephen mallette
stephen mallette

Reputation: 46226

When the keys of the Map you want to produce must be dynamically determined then you typically use group().

g.V().has('familyName','Smith').
  group().
    by('familyName').
    by(out().values('name'))

Upvotes: 1

Related Questions