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

huangapple go评论109阅读模式
英文:

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

问题

作为你的中文翻译,我将为你翻译以下内容:

所以,作为对Go和Cayley不熟悉的新手,我在向图中插入数据方面遇到了困难。我在命令行上运行一个gremlin控制台,使用以下命令:

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

我知道cayley使用的是Gremlin的一个不同变体。这个页面(https://github.com/google/cayley/wiki)说明它使用的是'Cayley-Gremlin'而不是'Tinkerpop-Gremlin'。我认为大部分API应该保持相同,但事实并非如此。这个文档说明图对象有一个可用的addVertex方法。然而,当我尝试在Cayley repl中使用这个方法时,我得到了一个错误:

cayley> g.addVertex("test")

Error: TypeError: 'addVertex'不是一个函数
-----------
1个结果
经过时间:0.102239毫秒

为什么图上没有这个方法?API有所不同吗?是否有另一种使用'Cayley-Gremlin'向图中插入节点/边的方法?

提前感谢!

英文:

So being new to Go and Cayley I am struggling with inserting data into the graph. I am running a gremlin console on the command line with this command:

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

I know cayley uses a different variant of Gremlin. This page (https://github.com/google/cayley/wiki) states that it uses 'Cayley-Gremlin' instead of '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. This documentation states that the graph object has an addVertex method available. However, when I try to use the method in the Cayley repl I get an error:

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? Is there another method of inserting nodes/edges into graphs using 'Cayley-Gremlin'?

Thanks in advance!

答案1

得分: 3

gremlin在Cayley中仅用于遍历。https://github.com/google/cayley/blob/master/docs/GremlinAPI.md 是Cayley的完整Gremlin API。

使用HTTP来添加数据:https://github.com/google/cayley/blob/master/docs/HTTP.md#apiv1write

英文:

gremlin in cayley is only for traversals. https://github.com/google/cayley/blob/master/docs/GremlinAPI.md is the complete gremlin API for cayley.

use http to add data: https://github.com/google/cayley/blob/master/docs/HTTP.md#apiv1write

答案2

得分: 0

我对Cayley还不太熟悉,但我认为以下命令是Gremlin中用于从REPL执行的添加新顶点的命令(对我来说,这是一种更方便的添加和删除的方式):

cayley> :a subject predicate object label .
英文:

I'm pretty new to cayley but I thought that

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)

huangapple
  • 本文由 发表于 2014年12月30日 04:29:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/27695557.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定