How to transverse the graph in multiple path


#1

I play around the 30kmoviedata.nq and would like to list out all the actor (real person name) and character names of a particular movie. The graph is like this: Imgur

This query can list out all actor names of the movie

var filmToActor = g.M().out("</film/film/starring>").out("</film/performance/actor>");

var list = g.V().has("<name>", "Cocktail")
.save("<name>", "filmName")
.follow(filmToActor)
.save("<name>", "actorName")
.all();

Out

{
	"result": [
		{
			"actorName": "Tom Cruise",
			"filmName": "Cocktail",
			"id": "</en/tom_cruise>"
		},
		{
			"actorName": "Bryan Brown",
			"filmName": "Cocktail",
			"id": "</en/bryan_brown>"
		},
		{
			"actorName": "Elisabeth Shue",
			"filmName": "Cocktail",
			"id": "</en/elisabeth_shue>"
		},
		{
			"actorName": "Laurence Luckinbill",
			"filmName": "Cocktail",
			"id": "</en/laurence_luckinbill>"
		},
		{
			"actorName": "Lisa Banes",
			"filmName": "Cocktail",
			"id": "</en/lisa_banes>"
		},
		{
			"actorName": "Kelly Lynch",
			"filmName": "Cocktail",
			"id": "</en/kelly_lynch>"
		},
		{
			"actorName": "Gina Gershon",
			"filmName": "Cocktail",
			"id": "</en/gina_gershon>"
		}
	]
}

What should be the query like in order to also show the character names like:

{
	"result": [
		{
			"actorName": "Tom Cruise",
			"filmName": "Cocktail",
			"characterName": "",
			"id": "</en/tom_cruise>"
		},
		{
			"actorName": "Bryan Brown",
			"filmName": "Cocktail",
			"characterName": "Doug Coughlin",
			"id": "</en/bryan_brown>"
		},
		// ...		
}