For the expected output format, this query's would probably come close to
it:
g.V().hasLabel("HUMAN").has("isLive", true).
match(__.as("x").out("have").hasLabel("CAR").as("car"),
__.as("x").out("have").hasLabel("HOUSE").as("house"),
__.as("x").out("drinked_by").values("name").fold().as("beers")).
group().
by(select("x").by("name")).
by(select("car","house","beers").
by("name").
by("name").
by().
fold())
Cheers,
Daniel
On Fri, Aug 24, 2018 at 9:23 AM [email protected] <[email protected]>
wrote:
> Hi guys,
> sorry could you help me with this query?
>
> Model:
> https://i.imgur.com/3n8MEzZ.png
>
> I need to read all information about all the humans alive and for any
> human the beers he loves, which car drives and in which house he lives.
>
> With one query, my difficulty is to maintain a hierarchical relationship
> between the human and the other nodes.
> I found this solution but I don't know if it's the best one:
>
>
> g.V().hasLabel("HUMAN").has("isLive",true).where(__.and(__.out("have").hasLabel("CAR"),__.out("have").hasLabel("HOUSE"))).both().hasLabel("BEER","CAR","HOUSE").valueMap().tree();
>
> my expect result is like this:
> [
> { Jon loves beer: Firestone, Bud , car: Mustang house: NYC},
> { Homer: beer:Duff, car: Plymouth house: SpringField},
> {Sasha beer: Bud,Firestone, Bud, car: Ford, house: Chicago}
> ]
> is it possible to do it with just one query? Could you help me?
> Thanks
>