简体   繁体   English

Gremlin - 基于遍历中找到的值的 select 顶点

[英]Gremlin - select vertices based on value found in traversal

I want to use the id of a vertex that has prop_a=x to find other vertices which have this value in some other property.我想使用具有 prop_a=x 的顶点的 id 来查找在其他属性中具有此值的其他顶点。
Something like:就像是:

g.V().sideEffect(has('prop_a','x').id().as('val')).has('prop_b',__.select('val')).count()

But the above doesn't return the right result.但是上面没有返回正确的结果。
In addition, I need it to run efficiently on AWS Neptun.此外,我需要它在 AWS Neptun 上高效运行。

Queries to create the data:创建数据的查询:

gremlin> g.addV().property(id,1).property('prop_a','x')
==>v[1]
gremlin> g.addV().property(id,2).property('prop_b',1)
==>v[2]

Query to get the desired data:查询以获取所需数据:

gremlin> g.V().
......1>   has('prop_a', 'x').
......2>   id().as('val').
......3>   V().as('b').
......4>   values('prop_b').
......5>   where(eq('val')).
......6>   select('b')
==>v[2]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM