我正在尝试找出哪些“过滤器”顶点具有多个具有相同标签的顶点的边。例如,在这种情况下,“ filter:2”有2条边将到达标签“ projectType”相同的顶点。 “ filter:3”也是如此,因为它有3条边到顶点“ projectType”。
我尝试尝试“循环”步骤,但总是从控制台收到错误消息。我正在使用AWS Neptune。
filter:1, filter
filter:2, filter
filter:3, filter
projectType:1, projectType
projectType:2, projectType
projectType:3, projectType
projectType:4, projectType
city:1, city
city:2, city
city:3, city
filter:1-projectType:1, services, filter:1, projectType:1
filter:2-projectType:1, services, filter:2, projectType:1
filter:2-projectType:2, services, filter:2, projectType:2
filter:3-projectType:2, services, filter:3, projectType:2
filter:3-projectType:3, services, filter:3, projectType:3
filter:3-projectType:4, services, filter:3, projectType:4
filter:1-city:2, services, filter:1, city:2
filter:2-city:1, services, filter:2, city:1
filter:3-city:1, services, filter:3, city:1
g.addV('filter').property('id','filter:1').as('f1').addV('filter').property('id','filter:2').as('f2').addV('filter').property('id','filter:3').as('f3').addV('projectType').property('id','projectType:1').as('p1').addV('projectType').property('id','projectType:2').as('p2').addV('projectType').property('id','projectType:3').as('p3').addV('projectType').property('id','projectType:4').as('p4').addV('city').property('id','city:1').as('c1').addV('city').property('id','city:2').as('c2').addV('city').property('id','city:3').as('c3').addE('services').from('f1').to('p1').addE('services').from('f2').to('p1').addE('services').from('f2').to('p2').addE('services').from('f3').to('p2').addE('services').from('f3').to('p3').addE('services').from('f3').to('p4').addE('services').from('f1').to('c2').addE('services').from('f2').to('c1').addE('services').from('f3').to('c1')
g.V().hasLabel('filter').as('x').outE().inV().loop('x').{it.loops < 3}.path()
{“ requestId”:“ d63968ad-6c63-41f8-bfff-b31b09077a92”,“代码”:“ MalformedQueryException”,“ detailedMessage”:“查询解析在第1行失败,字符位置为68,错误消息:令牌识别错误:“它”。“}
答案 0 :(得分:0)
鉴于您尝试解决问题的原因,我不清楚您想要什么,但是如果我以面值来考虑您的问题,您似乎想要获取具有多个标签且包含多个标签的“过滤器”顶点的列表将是“ filter:2”和“ filter:3”。如果是这样,那么:
gremlin> g.V().hasLabel('filter').
......1> filter(out().
......2> groupCount().by(label).
......3> unfold().
......4> select(values).
......5> is(gt(1))).
......6> values('id')
==>filter:2
==>filter:3
filter()
步骤在传出边缘上遍历,并计算相邻顶点上的所有标签。然后,在第3行上,展开Map
标签和计数的结果并仅提取计数(即select(values)
提取Map
条目中键/值对的值即计数),然后用is(gt(1))
过滤这些计数,表示当前顶点至少存在一种情况,即相邻顶点的标签不止一个