简体   繁体   English

Cayley:如何使用Cayley-Gremlin代码将顶点和边插入图形中?

[英]Cayley: How do insert vertices and edges into graph using Cayley-Gremlin code?

So being new to Go and Cayley I am struggling with inserting data into the graph. 因此,对于Go和Cayley来说,我是新手,我正努力将数据插入到图形中。 I am running a gremlin console on the command line with this command: 我正在使用以下命令在命令行上运行gremlin控制台:

cayley repl --db="bolt" --dbpath=../../database/database1 --query_lang="gremlin"

I know cayley uses a different variant of Gremlin. 我知道Cayley使用Gremlin的其他变体。 This page ( https://github.com/google/cayley/wiki ) states that it uses 'Cayley-Gremlin' instead of 'Tinkerpop-Gremlin'. 此页面( https://github.com/google/cayley/wiki )指出它使用的是“ Cayley-Gremlin”而不是“ Tinkerpop-Gremlin”。 I would think that for the most part the API would remain the same, but that doesn't seem to be the case. 我认为在大多数情况下,API都将保持不变,但事实并非如此。 This documentation states that the graph object has an addVertex method available. 文档指出该图形对象具有可用的addVertex方法。 However, when I try to use the method in the Cayley repl I get an error: 但是,当我尝试在Cayley repl中使用该方法时,出现错误:

cayley> g.addVertex("test")

Error: TypeError: 'addVertex' is not a function
-----------
1 Results
Elapsed time: 0.102239 ms

Why is the method not available on the graph? 为什么该方法在图形上不可用? Is the API different? API是否不同? Is there another method of inserting nodes/edges into graphs using 'Cayley-Gremlin'? 还有另一种使用“ Cayley-Gremlin”将节点/边插入图形的方法吗?

Thanks in advance! 提前致谢!

gremlin in cayley is only for traversals. Cayley中的gremlin仅用于遍历。 https://github.com/google/cayley/blob/master/docs/GremlinAPI.md is the complete gremlin API for cayley. https://github.com/google/cayley/blob/master/docs/GremlinAPI.md是用于cayley的完整gremlin API。

use http to add data: https://github.com/google/cayley/blob/master/docs/HTTP.md#apiv1write 使用http添加数据: https : //github.com/google/cayley/blob/master/docs/HTTP.md#apiv1write

I'm pretty new to cayley but I thought that 我是Cayley的新手,但我认为

cayley> :a subject predicate object label .

Was a command of gremlin to add new vertex executed from repl (for me, a much more convenient way to do adding and deleting ( :d ) 是gremlin的命令,用于添加从repl执行的新顶点(对我来说,这是添加和删除( :d )的更方便的方法

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM