Я хочу получить вложенные объекты в виде
{ country :
{code:'IN',states:
{code:'TG',cities:
{code:'HYD',malls:
{[shopping-mall1],[shopping-mall2],.....}
},
{code:'PKL',malls:
{[shopping-mall1],[shopping-mall2],.....}
}
},
{code:'AP',cities:
{code:'VJY',malls:
{[shopping-mall1],[shopping-mall2],.....}
}
}
}
}
МОЙ график имеет формат
vertex: country ---> states ---->cities ---> mallls
edges: (type:'state') ('type','city')
ex: inE('typeOf').outV().has('type','state') move to next vertex "states".
next same inE('typeOf').outV().has('type','city') moves to "city" vertex. then "malls" vertex .
И устал писать код, в какой-то вершине нет городов, у меня ошибка ситуационная. "
ошибка
The provided traverser does not map to a value: v[8320]->[JanusGraphVertexStep(IN,[partOf],vertex), HasStep([type.eq(city)]), JanusGraphPropertiesStep([code],value)]
Вот почему я использую coalesce, потому что в каком-то штате нет края 'inE (' partOf '). OutV (). Has (' type ',' city ')' означает отсутствие города
.by(coalesce(select('states').inE('partOf').outV().has('type','city'))
Мой запрос
g.V().hasLabel('Country').has('code','IN')
.project('country')
.by(project('code','states')
.by(values('code'))
.by(inE('partOf').outV().has('type','state').has('code').as('states').
project('code','cities')
.by(select('states').values('code'))
.by(coalesce(select('states').inE('partOf').outV().
has('type','city').has('code').as('cities').
project('code','malls')
.by(select('cities').values('code'))
.by(coalesce(select('cities').inE('partOf').outV().
has('type','malls').valueMap(),constant(0))),
constant(0)))))
Но результат
{country={code=IN, states={code=DD, cities=0}}}
here i am getting one state 'DD' and that state is no city,so it gives 'cities = 0".
приведенный выше результат - только один штат, я хочу, чтобы все штаты, города и торговые центры в каждом городе.
Пожалуйста, обновите запрос или измените запрос
g.addV()...
)? - person Daniel Kuppitz   schedule 10.08.2019