gpt4 book ai didi

gremlin - 图未保存

转载 作者:行者123 更新时间:2023-12-04 02:45:44 25 4
gpt4 key购买 nike

首先,我按照以下步骤在 JanusGraph 中创建一个图表。

  • 将以下内容添加到 conf/janusgraph-cassandra-configurationgraph.properties
index.search.backend = elasticsearch
index.search.hostname = 127.0.0.1
index.search.elasticsearch.transport-scheme = http
  • 将 gremlin-server-configuration.yaml 中的“ConfigurationManagementGraph:conf/janusgraph-cql-configurationgraph.properties”更改为“ConfigurationManagementGraph:conf/janusgraph-cassandra-configurationgraph.properties”

  • 将 conf/gremlin-server/gremlin-server.yaml 更改为 conf/gremlin-server/gremlin-server.yaml.orig

  • 将 conf/gremlin-server/gremlin-server-configuration.yaml 更改为 conf/gremlin-server/gremlin-server.yaml

  • 运行 bin/janusgraph.sh 开始

  • 运行 bin/gremlin.sh

  • 运行

:remote connect tinkerpop.server conf/remote.yaml session
:remote console

map = new HashMap<String, Object>();
map.put("storage.backend", "cassandrathrift");
map.put("storage.hostname", "127.0.0.1");
map.put("graph.graphname", "KG");
map.put("index.search.backend", "elasticsearch");
map.put("index.search.hostname", "127.0.0.1");
map.put("index.search.elasticsearch.transport-scheme", "http");

ConfiguredGraphFactory.createConfiguration(new MapConfiguration(map));
graph=ConfiguredGraphFactory.open("KG");

g=graph.traversal();


ConfiguredGraphFactory.getGraphNames()
  • 关闭 janusgraph,运行 bin/janusgraph.sh stop

  • 将 conf/janusgraph-cassandra-es.properties 复制到 conf/KG.properties

  • 将下面两行添加到conf/KG.properties的顶部

gremlin.graph=org.janusgraph.core.ConfiguredGraphFactory
graph.graphname=KG
  • 打开 conf/gremlin-server/gremlin-server.yaml,并将以下行添加到图表中:
KG: conf/KG.properties
  • 将“scripts/empty-sample.groovy”添加到“org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin:”

  • 打开 script/empty-sample.groovy,将最后一行更改为以下内容:

globals << [g : KG.traversal()]
  • 运行 bin/janusgraph.sh start 再次启动 janusgraph

其次,我运行 bin/gremlin.sh

  • 运行
:remote connect tinkerpop.server conf/remote.yaml session
:remote console
graph=ConfiguredGraphFactory.open("KG");
g=graph.traversal();
g.addV('user').property('name', 'Robert')
g.V()
  • 我可以看到它返回一个顶点 ==>v[4120]

第三,然而,当我退出 gremlin 控制台,并像上面一样再次进入 gremlin 控制台时,当我尝试查询 g.V() 时,我没有看到任何返回。

知道为什么会这样吗?非常感谢!

最佳答案

我认为这是因为您在添加顶点后未能使用 g.tx().commit() 关闭事务。

请注意,Gremlin Server 确实会管理 session 并为您调用 commit(),但通过执行以下操作:

:remote connect tinkerpop.server conf/remote.yaml session

您已经明确打开了一个不管理 session 的连接。如果您想要一个受管理的 session 并在每次请求时自动提交,那么您需要执行以下操作:

:remote connect tinkerpop.server conf/remote.yaml session-managed

http://tinkerpop.apache.org/docs/current/reference/#console-sessions

关于gremlin - 图未保存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57334989/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com