Nested query or recursive query or inner query

Skip to first unread message

Sumit Suman

Nov 8, 2021, 12:06:35 AM11/8/21
to Gremlin-users
Hi Team, 

I am struggling to get the working syntax for nested queries or recursive queries. I searched a lot but none of them are working queries. Kindly help me to get the syntax

I have both the query, I am not able to put both queries as an inner query

Query 1:
g.V().hasLabel('Texas').outE('feature of')
    "id": "5b3e7178-5a06-4afc-8c25-54f2a91a117e",
    "label": "feature of",
    "type": "edge",
    "inVLabel": "xyz",
    "outVLabel": "abc",
    "inV": "111",
    "outV": "2222",
    "properties": {
      "weight": "75.625",
      "test": "test"

Query 2:
g.V().has('id','5235h-j3h5k3-j3gj23').emit().repeat(inE('child of').outV())

So basically, in the 2nd query, I need to pass the "id" of the 1st query.


Stephen Mallette

Nov 9, 2021, 8:11:20 AM11/9/21
I don't quite follow your question. Your first traversal returns an Edge, but then you mention you want to take the id of that edge and pass that to the second traversal. That part is confusing because your traversal starts with a Vertex. I think you need to clarify what id you wish to pass, where it fits in your traversal and what results you expect. 

You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Phil Crosland

Nov 9, 2021, 11:19:33 AM11/9/21
to Gremlin-users
something like 
g.V().hasLabel('Texas').outE('feature of').as('a').V().has('id','a').by('id')) ?

Sumit Suman

Nov 12, 2021, 7:34:59 AM11/12/21
to Gremlin-users
Yes, my first traversal returns an edge that has both inV() and outV() ID(Response of 1st query has it) and I want to use that ID to get details of any of both vertex in a single query.
Such that once I will the query I would get to know the details of the connected node instead of edge details.

I executed below query

g.V().hasLabel('Texas').outE('feature of')

and got outV() details as  "2222". Now I want to use "2222" inside the next query to get that vertex's details.

In Sql term,
Select S_ID from STUDENT_COURSE where C_ID IN (SELECT C_ID from COURSE where C_NAME = ‘DSA’ or C_NAME=’DBMS’)

Kindly do let me know if still any clarifications required.

Reply all
Reply to author
0 new messages