如何在单个gremlin查询中添加多个边? [英] How to add multiple edges in a single gremlin query?

查看:265
本文介绍了如何在单个gremlin查询中添加多个边?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况是在单个查询中在顶点之间添加多个边:

My scenario is to add multiple edges between vertices in a single query:

假设以下节点: 这些是我拥有的标签和ID

Assume the nodes below: These are the labels and ids I have

用户:

4100

歌曲:

4200

4355

4676

我必须在这些顶点之间建立边缘

I have to establish edges between these vertices

4100 --> 4200, 
4100 --> 4355, 
4100 --> 4676.

我们通常可以通过在节点之间创建单个边来完成此操作.如果我们想一次在50个以上的顶点之间创建边,则这不是一种有效的方法.我正在使用Tinkerpop 3.0.1.

We can do it normally by creating single edge between node.it is not a efficient method if we want to create edge between more than 50 vertices at a time. I am using Tinkerpop 3.0.1.

推荐答案

如果有顶点ID,则按ID查找是非常有效的.如果您使用的是Gremlin Server,则对Gremlin Server的每个请求都将被视为单个事务.您可以对单个请求(带有绑定)在Gremlin查询中传递多个语句,而不是发送多个请求.用分号分隔Gremlin查询中的语句.

If you have the vertex ids, it is very efficient to lookup by id. If you are using Gremlin Server, each request to the Gremlin Server is treated as a single transaction. You can pass the multiple statements in a Gremlin query on a single request (with bindings) rather than sending multiple requests. Separate the statements in the Gremlin query with semicolons.

l=[4200, 4355, 4676]; v=graph.vertices(4100).next(); l.each { v.addEdge("knows", graph.vertices(it).next()) }

这篇关于如何在单个gremlin查询中添加多个边?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆