How to pipe selected property from one gremlin query to another?

Viewed 194

I'm trying to pass the selected properties from one traversal to another. But it is not working with pure gremlin way.

g.V().has('pname', name).has('version', within(V().has('ecosystem', ecosystem).has('name', name).values('latest_version', 'latest_non_cve_version').))

However it works when I split the above query into multiple statements.

x = g.V().has('ecosystem', ecosystem).has('name', name).values('latest_version', 'latest_non_cve_version').toList(); g.V().has('pname', name).has('version', within(x))

Is there a way to achieve the same with pure gremlin way?

1 Answers

The within predicate cannot take a traversal. You should be able to do what you need by simply reversing the two parts of the query. As I don't have your data I am showing an example that uses the air-routes data set. The query you need will end up being something like this:

gremlin> g.V().has('region',within('US-NM','US-TX')).
               values('region').
               fold().as('a').
           V().hasLabel('airport').
               where(within('a')).
                 by('region').
                 by().
               count()
==>36
Related