简体   繁体   中英

How to drop an edge in Gremlin?

I currently have this state of my graph database. I've SSH'ed into my EC2 instance and from there connected to my Amazon Neptune database.

 g.V()
==>v[26b648fe-b972-a1b4-1642-1ef06ae42a87]
==>v[2]
==>v[6]
==>v[1]
==>v[3]
==>v[7cb648ff-2791-229a-50eb-2408938b42ba]
==>v[4]
==>v[5]
gremlin>  g.E()
==>e[62b648fe-fd52-d10f-71d6-f15edd014a13][1-knows->4]
==>e[acb648ff-06b9-8526-846f-f03e5c08d6bc][6-created->3]
==>e[2cb648ff-0663-6343-2d40-ea535087771b][1-created->3]
==>e[4cb648fe-fd13-8a2b-049f-b65ddd7bd3d7][1-knows->2]
==>e[0eb648ff-0678-90d1-d77f-69b1733d4c95][4-created->5]
==>e[74b648ff-0686-3018-c0cf-2f4b15dcd4e2][4-knows->3]
gremlin>  g.V().has("name", "marko").outE('knows')
==>e[4cb648fe-fd13-8a2b-049f-b65ddd7bd3d7][1-knows->2]
==>e[62b648fe-fd52-d10f-71d6-f15edd014a13][1-knows->4]

So what is 4cb648fe-fd13-8a2b-049f-b65ddd7bd3d7 ? Is this some kind of ID?

1 knows 4, 3, 2. How do I make it so that 1 only knows 1 and 4?

4cb648fe-fd13-8a2b-049f-b65ddd7bd3d7 is the id of the edge between 1 and 2.

If you want to drop all edge from 1 to any vertex besides 1 and 4 you can run:

g.V('1').outE('knows').where(inV().not(hasId('1', '4'))).drop()

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