标签: gremlin-server

查找具有特定关系的所有间接连接的节点Gremlin

假设我在Gremlin中使用了Node的数字ID

g.V(n_id)
Run Code Online (Sandbox Code Playgroud)

说这个节点是一个主题.

每个主题都可以有一个关系问题threadOf.

每个问题都可以有关系的答案或评论 threadOf

如果我得到一个数字ID作为输入,我想要一个gremlin查询,它返回与该主题相关的所有问题以及与这些问题相关的所有答案或评论

所有关系都是 threadOf

Gremlin有可能吗?

graph-databases gremlin gremlin-server janusgraph

2
推荐指数
1
解决办法
487
查看次数

如何获得满足特定条件的所有顶点组成的子图

文献修订是驻留在我们的域逻辑的特定层的两个对象.

文件表示周围的任何材料一张纸,你能想到的抽象.也就是说 - 每份合同,发票或图纸都可以称为文件.

另一方面,文档的材料表示是修订:建筑工程师在现场接收的纸张列表表示设计者创建的文档修订版.如果由于错误或需求更改而必须更改图形中的某些内容,则会在现场显示新修订 - 同一文档的修订版#2.

版本可能包含指向其他文件 ; 因此,我们可以描述汽车,车门,发动机,车轮等之间的关系,以及每个元素独立演变的可能性,同时保持与其他元素的联系.

显示典型的DAG:

汽车元素 - 文件和修订

我设法使用C#Graph API将所有顶点和边插入到CosmosDB中.我设法遍历图表并执行简单查询,以便查找汽车有多少修改,或者发动机在最初创建时是否有涡轮增压器.但是,我正在努力编写一个复杂的查询,它只返回每个部分或汽车的最新版本,或者返回汽车状态的查询,直到2016-08-10.

该车的状态截至2017-01-03: 成品车

该车的状态可达2016-08-10: 汽车发动机还没有涡轮增压器

当遍历访问顶点的后代(它的"out()")时,我找不到一种方法来获取最近创建的并继续遍历而不挖掘其他顶点.如果你建议我一个表达式,我只会从图片中返回彩色顶点,我将不胜感激.

gremlin tinkerpop3 gremlin-server azure-cosmosdb

2
推荐指数
1
解决办法
369
查看次数

JanusGraph 事务和配置

我可以在单个事务中创建的最大顶点和边数是多少,更多的是如何配置 JanusGraph 服务器堆以为其添加更多内存。提前致谢。

gremlin gremlin-server janusgraph

2
推荐指数
1
解决办法
733
查看次数

如何在Gremlin中找到两个顶点之间的Edge ID

假设我们有一个包含许多顶点的图g,我们需要在顶点v1和具有ID id1id2的顶点v2之间找到边和ID .

graph gremlin gremlin-server

2
推荐指数
1
解决办法
885
查看次数

Gremlin-Python:返回完全填充的子图

我正在使用Gremlin-Python Client查询带有janusgraph后端的Gremlin Server。

运行以下查询:

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
sg = g.E().subgraph('a').cap('a').next()
Run Code Online (Sandbox Code Playgroud)

查询返回一个子图,其中包含边和顶点的列表。

我在服务器上配置了以下序列化器

serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV3d0, config: { serializeResultToString: true }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV3d0, config: { ioRegistries: [org.janusgraph.graphdb.tinkerpop.JanusGraphIoRegistry] }} 
Run Code Online (Sandbox Code Playgroud)

有谁知道如何配置gremlin-server和示例代码以返回完全填充的子图?

根据Stephen的反馈更新了测试用例

# DB: Janusgraph with Opensource Cassandra storage backend
# Data: v[41427160]--reports_to-->v[36712472]--reports_to-->v[147841048]
# Objective: get subgraph detached to python client with all properties of the vertex and edges

(py365)$ pip list | grep gremlinpython
gremlinpython   3.3.4 …
Run Code Online (Sandbox Code Playgroud)

gremlin gremlin-server janusgraph gremlinpython

2
推荐指数
1
解决办法
582
查看次数

具有 id 的边缘已存在 - Gremlin

我正在使用 Gremlin 使用以下内容更新插入边缘。我正在遵循这里提到的食谱。这是我正在使用的代码。该代码在 lambda 中运行,该 lambda 与 Amazon Neptune 中托管的集群进行通信

    public void createEdge(final String id, final String label, final String fromId, final String toId, final Map<String, String> properties) {
        this.graphTraversalSource
            .V(fromId) // get vertex of id given for the source
            .as("fromVertex") // label as fromVertex to be accessed later
            .V(toId) // get  vertex of id given for destination
            .coalesce( // evaluates the provided traversals in order and returns the first traversal that emits at least one element
                inE(label) …
Run Code Online (Sandbox Code Playgroud)

gremlin tinkerpop tinkerpop3 gremlin-server amazon-neptune

2
推荐指数
1
解决办法
1604
查看次数

Janusgraph - 关于在创建模式和索引后迭代所有顶点的警告

我将 JanusGraph 与 Cassandra 和 ElasticSearch 后端一起使用。我使用以下脚本来创建我的架构和索引。

// Create a Janus Graph instance, according to the configuration file provided
// in the open() method below, and define the schema and index.
// This is intended to be loaded and run inside the Gremlin Console from the Janus
// Graph download. Usage :load janus-ualschema.groovy

println "\n=======================================";[]
println "Creating in-memory Janus Graph instance";[]
println "=======================================\n";[]
// Create a new graph instance
graph = JanusGraphFactory.open("conf/janusgraph-useractivitylogs.properties")
mgmt = graph.openManagement()

println "\n====================";[]
println "Defining EDGE …
Run Code Online (Sandbox Code Playgroud)

gremlin tinkerpop3 gremlin-server janusgraph

1
推荐指数
1
解决办法
1488
查看次数

工作 gremlin javascript 示例

有一个新版本,但文档有点缺乏工作示例。

Github 票证:https : //github.com/jbmusso/gremlin-javascript/issues/109

我一直在努力让一个例子起作用。任何帮助表示赞赏:

gremlin-server: 3.3.2 with config gremlin-server-modern.yaml
npm gremlin lib: 3.3.2

import gremlin from 'gremlin';
import DriverRemoteConnection from 'gremlin/lib/driver/driver-remote-connection';
import { Graph } from 'gremlin/lib/structure/graph';
const graph = new Graph()
const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', { mimeType: 'application/vnd.gremlin-v3.0+json' }));

const fetchById = async (id) => {
  const result = await g.V(id).toList()
  console.log(result);
}

const addUser = async (name) => {
  const newVertex = await g.addV().property('name','marko').property('name','marko a. rodriguez').next()
  console.log(newVertex)
}

addUser()
fetchById(0)
Run Code Online (Sandbox Code Playgroud)

电流输出:

[]
{ value: …
Run Code Online (Sandbox Code Playgroud)

javascript gremlin gremlin-server

1
推荐指数
1
解决办法
4290
查看次数

JanusGraph/tinkerpop 中的连接泄漏

我通过远程连接到 janusGraph

cluster = Cluster.build()
                .addContactPoints(uri.split("\\|"))
                .port(port)
                .serializer(new GryoMessageSerializerV1d0(GryoMapper.build().addRegistry(JanusGraphIoRegistry.getInstance())))
                .maxConnectionPoolSize(poolSize)
                .maxContentLength(10000000)
                .create();
        gts = AnonymousTraversalSource
                .traversal()
                .withRemote(DriverRemoteConnection.using(cluster));
Run Code Online (Sandbox Code Playgroud)

由于 gts 是线程安全的,我将 gts 保持在静态上下文中。每个线程使用相同的对象,并且没有一个线程通过调用 gts.close() 关闭 gts 每个线程运行查询,例如: result = gts.V().has("foo","bar").valueMap().toList() 我不关闭 gts(graphTraversalSource) 不是由创建的 graphTraversal 对象gts.V()

  • 我应该关闭从 gts(graphTraversalSource) 创建的每个 graphTraversal 对象吗?
  • 我应该什么时候关闭这些对象?

gremlin tinkerpop tinkerpop3 gremlin-server janusgraph

1
推荐指数
1
解决办法
122
查看次数

从 gremlin 数据库获取数据并在 nodejs 中迭代

我是小鬼的新手。使用 nodejs 我连接了 gremlin 并添加了几个顶点。

假设我有 10 个不同的顶点并与边相连。有没有办法读取和迭代nodejs中的数据。它就像带有条件的简单选择查询..(选择 * from users where username='john')

 async get_vertices_by_props(input) {
        
        var graph_data = await this.get_vertex(input.label,input.property_name)
         // some code here.. 
     
    }

async get_vertex(label, property) {
        if (!label || !property || !value) {
            return error;
        }
        return await this.g.V().hasLabel(label);
    }
Run Code Online (Sandbox Code Playgroud)

cassandra node.js gremlin gremlin-server janusgraph

1
推荐指数
1
解决办法
241
查看次数