Получить все вершины с определенным свойством, меткой и идентификатором вдоль пути - PullRequest
1 голос
/ 24 сентября 2019

У меня есть следующая структура в базе данных Janusgraph:

gremlin> continent = g.addV("continent").property("name", "Europe").next()
gremlin> country = g.addV("country").property("name", "France").next()
gremlin> region = g.addV("region").property("name", "Ile-de-France").next()
gremlin> departement = g.addV("departement").property("name", "Hauts-de-Seine").next()
gremlin> city = g.addV("city").property("name", "Saint-Cloud").next()
gremlin> g.V(continent).addE('is_part_of').to(country).iterate()
gremlin> g.V(country).addE('is_part_of').to(region).iterate()
gremlin> g.V(region).addE('is_part_of').to(departement).iterate()
gremlin> g.V(departement).addE('is_part_of').to(city).iterate()

Я сделал, чтобы получить свойство name от всех вершин от город до континент отследующий запрос:

gremlin> g.V(city).emit().repeat(inE("is_part_of").outV().simplePath()).path().unfold().dedup().values("name")
==>Saint-Cloud
==>Hauts-de-Seine
==>Ile-de-France
==>France
==>Europe

Но я бы хотел получить также id и label каждой возвращаемой вершины.Я попытался использовать valueMap(true) вместо values("name") step, чтобы получить все свойства, включая id и label, но большая часть вершин содержит множество свойств, которые могут сильно повлиять на уровень производительности.Можно ли получить эти значения из каждой вершины?

1 Ответ

1 голос
/ 24 сентября 2019

Вы могли бы просто сделать valueMap(true, 'name')

gremlin> g.V(city).emit().repeat(inE("is_part_of").outV().simplePath()).
......1>   path().
......2>   unfold().
......3>   dedup().
......4>   valueMap(true,'name')
==>[id:8,label:city,name:[Saint-Cloud]]
==>[id:13,label:is_part_of]
==>[id:6,label:departement,name:[Hauts-de-Seine]]
==>[id:12,label:is_part_of]
==>[id:4,label:region,name:[Ile-de-France]]
==>[id:11,label:is_part_of]
==>[id:2,label:country,name:[France]]
==>[id:10,label:is_part_of]
==>[id:0,label:continent,name:[Europe]]
...