I am trying to drop all vertices returned by a given Gremlin query. The goal is to delete all children vertices which are children of a specific vertex.
Here's an example:
gremlin> g.V('dcb26be6-8d39-ae81-6ef2-6f60d06bce10').emit().repeat(out())
==>v[dcb26be6-8d39-ae81-6ef2-6f60d06bce10]
==>v[16b26be6-8d37-e882-38c6-a56f39ee4259]
==>v[9cb26be6-8d3c-d61e-4ab4-6c6993e8be7a]
==>v[82b26be6-8d3a-c01a-3771-085c94d1780a]
==>v[00b26be6-8d3c-68d9-6871-702a1247a692]
==>v[d4b26be6-8d38-81ea-b75d-25bbf563f81e]
==>v[cab26be6-8d39-3611-76fa-f369eab9d50e]
This query returns all vertices that have outward facing edges connected to the parent dcb26be6-8d39-ae81-6ef2-6f60d06bce10
vertex. Is there an easy way to drop all of the vertices returned by this query?
Thanks
EDIT:
@stephan had a great response however if the children have edges pointing to eachother gremlin gets mad at me. Check this out:
gremlin> g.V('2ab26c9e-1bbb-73f6-4ee8-6cecc7e21ee1').emit().repeat(out()).fold().unfold()
==>v[2ab26c9e-1bbb-73f6-4ee8-6cecc7e21ee1]
==>v[0eb26c9e-1bbc-12f3-e074-d7328ee4984e]
**==>v[92b26c9e-1bbd-b59f-0b5f-d4c985b176b6]**
==>v[18b26c9e-1bbf-a96c-90d3-e50e61fe7267]
==>v[12b26c9e-1bc1-40ee-292d-2bc7b08dcb9e]
==>v[ccb26c9e-1bbc-a82a-532f-7fbdea87deb1]
==>v[42b26c9e-1bbd-5f1f-f3ad-6f6670ab16ee]
==>v[7ab26c9e-1bc1-e773-6995-18159d610b77]
==>v[3ab26c9e-1bbe-add8-2ab2-948d7c9c0021]
**==>v[2eb26c9e-1bbf-1657-e212-98d1dfff33cd]**
**==>v[92b26c9e-1bbd-b59f-0b5f-d4c985b176b6]**
==>v[8cb26c9e-1bc2-500b-ae27-370a0cc4d392]
==>v[42b26c9e-1bc0-b4b0-4d54-fc7f20ca71d4]
==>v[7ab26c9e-1bc1-e773-6995-18159d610b77]
==>v[3ab26c9e-1bbe-add8-2ab2-948d7c9c0021]
**==>v[2eb26c9e-1bbf-1657-e212-98d1dfff33cd]**
As you can see vertex 92b26c9e-1bbd-b59f-0b5f-d4c985b176b6 appears twice as a response to this query. So when I try to do g.V('2ab26c9e-1bbb-73f6-4ee8-6cecc7e21ee1'). emit(). repeat(out()). fold(). unfold()
Here's the response I get
gremlin> g.V('2ab26c9e-1bbb-73f6-4ee8-6cecc7e21ee1'). emit(). repeat(out()). fold(). unfold().drop()
{"requestId":"2def0086-d71f-42e4-9c5f-c692d07cc96a","detailedMessage":"The
vertex does not exist 92b26c9e-1bbd-b59f-0b5f-
d4c985b176b6","code":"ConstraintViolationException"}
Is there any way to remove duplicates from the initial query?