英文:
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
)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论