简体   繁体   English

Gremlin - 选择一个顶点,在单个查询中创建新的顶点和边

[英]Gremlin - select a vertex, create new vertices and edges in single query

I have a user vertex already created.我已经创建了一个用户顶点。

g.V().has('user','username','vipul').as('user')

I want to create a new 'group' vertex with some properties and also a new 'options' vertex with some other properties.我想创建一个具有某些属性的新“组”顶点,以及一个具有其他一些属性的新“选项”顶点。

g.addV(label,'group','group_name','DC11').as('group')
g.addV(label,'options','command_line_arguments','-D -n').as('options')

Now I want to create an edge from user to group and another edge from group to options.现在我想创建一条从用户到组的边,以及从组到选项的另一条边。

user ---> group,   group ---> options

Can these queries be combined, selecting a vertex, creating new vertices and then creating new edges?是否可以组合这些查询,选择一个顶点,创建新顶点,然后创建新边?

You can simply chain the steps together:您可以简单地将这些步骤链接在一起:

g.V().has('user','username','vipul').as('user').
  addV('group').property('group_name','DC11').as('group').
  addE('memberOfGroup').from('user').
  addV('options').property('command_line_arguments','-D -n').
  addE('hasOptions').from('group')

Note that I set the properties with the property step as I prefer that form, but you can also add them directly with the addV step.请注意,我使用property步骤设置属性,因为我更喜欢该表单,但您也可以使用addV步骤直接添加它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gremlin:在单个gremlin查询中添加多个顶点? - Gremlin : Add multiple vertices in single gremlin query? Gremlin - 在单个查询中从多个顶点获取 select 属性的最佳方法 - Gremlin - Best way to select properties from multiple vertices in single query 在 Gremlin 中围绕具有传出和传入边的单个节点创建子图查询 - Create subgraph query in Gremlin around single node with outgoing and incoming edges 如何从顶点 scala gremlin 获取所有传入/传出边的所有顶点 - How to get all vertices of all incoming/outgoing edges from a vertex scala gremlin 如何从 Gremlin 中的特定顶点找到没有特定边的顶点? - How do I find vertices without particular edges from a particular vertex in Gremlin? 如何从顶点 scala gremlin 获取所有传出边的所有顶点 - How to get all vertices of all outgoing edges from a vertex scala gremlin 在 gremlin 查询中选择多个边和顶点 - Select multiple edges and vertexes in a gremlin query Gremlin:确定另一个顶点的所有连接中的顶点 - Gremlin: Determine vertices that are in all connections of another vertex 通过另一个顶点查询顶点 [GREMLIN] - Querying Vertices through another vertex [GREMLIN] 如何在单个查询中遍历gremlin中的根顶点 - How to traverse back to root vertex in gremlin in one single query
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM