使用 TinkerPop3 Restful 接口连接到 Titan Graph DB

Connect to Titan Graph DB with TinkerPop3 Restful Interface

我是 Titan/Gremlin/TinkerPop3 的新手,正在玩 around/experimenting 和 Restful API 数据库中 create/modify/delete vertices/edge 的接口。

我基本上想看看是否可以使用 tinkerpop3 公开的 API 进行图形处理。

我使用以下方法在 gremlin 服务器中创建了现代图形:

gremlin> graph = TinkerFactory.createModern()
gremlin> g = graph.traversal()

我可以通过 restful API 连接到 Titan 并执行:

curl "http://localhost:8182?gremlin=100-1"
{"requestId":"c2dfb667-0fbe-4796-9a5b-cc472487a5b0","status":{"message":"","code":200,"attributes":{}},"result":{"data":[99],"meta":{}}}

但是下面的 return 什么都没有:

curl http://localhost:8182 -d '{"gremlin": "g.V()"}'
{"requestId":"8ba30f35-31e7-46ff-b16e-3e01fb9a49bf","status":{"message":"","code":200,"attributes":{}},"result":{"data":[],"meta":{}}}

我的阅读来自:http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#_connecting_via_rest

非常感谢任何帮助。提前致谢。

最初与 Gremlin 控制台交互时,您创建了一个内存中的 TinkerGraph。您根本没有与 Gremlin 服务器交互,因此当您退出控制台时,该图表丢失了。

Gremlin 服务器提供的图形在 gremlin-server.yaml 文件中配置。它的配置在 TinkerPop documentation.

中有更深入的描述

如果你看看这个example configuration from TinkerPop, the graph configuration is for an empty TinkerGraph, but there is an additional script that loads the modern graph。要使用此配置 运行,请在启动服务器时将其作为参数传递:

./bin/gremlin-server.sh ./conf/gremlin-server-rest-modern.yaml

同样的方法也可以用于 Titan,但我强烈建议您先学习 TinkerPop,然后再深入学习 Titan。 TinkerPop 为 Titan 的图形结构和查询基础设施提供了坚实的基础。