我想知道是否有任何方法可以导出带有所有顶点/边的 Gremlin 数据库。最好输出是一个 Gremlin 遍历列表,如果需要,可以再次完全(甚至部分)导入。
这是作为工具存在还是在 TinkerPop 控制台客户端中存在?
自从我使用 CosmosDB 以来,我一直在尝试 Azure 的数据迁移工具,但它对我不起作用。使用 graphson() 对我也不起作用,但我可能一直在以错误的方式使用它。
gremlin> graph.io(graphson()).writeGraph("/tmp/output.json");
No such property: graph for class: groovysh_evaluate
最佳答案
我不知道有任何工具可以做到这一点:
我知道的所有导出工具都将导出为某种外部格式的文本或二进制格式。您必须通过编写一些 Gremlin 来自己创建这样的功能,这些 Gremlin 将以允许您在客户端生成遍历的 String
或 Bytecode
表示的方式返回数据。我认为您可以将其导出为边缘列表:
gremlin> g.V().has('person','name','marko').
......1> outE().
......2> project('edgeLabel','weight','inV','outV').
......3> by(label).
......4> by('weight').
......5> by(inV().valueMap(true)).
......6> by(outV().valueMap(true))
==>[edgeLabel:created,weight:0.4,inV:[id:3,label:software,name:[lop],lang:[java]],outV:[id:1,label:person,name:[marko],age:[29]]]
==>[edgeLabel:knows,weight:0.5,inV:[id:2,label:person,name:[vadas],age:[27]],outV:[id:1,label:person,name:[marko],age:[29]]]
==>[edgeLabel:knows,weight:1.0,inV:[id:4,label:person,name:[josh],age:[32]],outV:[id:1,label:person,name:[marko],age:[29]]]
或星图样式:
gremlin> g.V().has('person','name','marko').
......1> project('v','edges').
......2> by(valueMap(true)).
......3> by(bothE().
......4> project('e','inV','outV').
......5> by(valueMap(true)).
......6> by(valueMap(true)).
......7> by(valueMap(true)))
==>[v:[id:1,label:person,name:[marko],age:[29]],edges:[e:[id:9,label:created,weight:0.4],inV:[id:9,label:created,weight:0.4],outV:[id:9,label:created,weight:0.4]]]
上述查询仅提供基本结构。您可以提出更好的形式、更有效的表示等,但所提供的数据提供了在客户端构建遍历所需的所有数据。
关于azure - 导出 Gremlin 数据库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57807193/