简体   繁体   中英

Gremlin query to select vertex based on count of out edges on a particular subset of out vertex

For example, there are two types of vertex in Graph [ Account, User]. Account vertexes have edges to user vertex denoting a list of users form an Account vertex. User vertex has two property ( name, phoneNumber). I want to select accounts who are connected to more than 2 users whose name starts with foo.

The output should not contain accounts who have more than 2 edges to User vertex but out of all those users, only 1 user's name starts with foo. At minima, 2 users should have name which starts with foo.

This query would do it:

g.V().hasLabel("Account")
.where(out().hasLabel("User")
.has("name", startingWith("foo"))
.count().is(gte(2)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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