目前,通过一次遍历,我可以执行以下操作:
Edge edge = g.E().Next();
var inv = edge.InV;
var outv = edge.OutV;
var id = edge.Id;
Run Code Online (Sandbox Code Playgroud)
这使我能够获取边的 id,以及边所经过的顶点的 id。或者,我可以这样做:
IDictionary<object, object> dict = g.E().ValueMap<object, object>(true).Next();
var id = dict[T.id]
var edgeProp = dict["$edgePropertyName"];
Run Code Online (Sandbox Code Playgroud)
这允许我获取属性和 id,但不能获取边缘的 id。有没有办法在一次遍历中同时获取顶点和属性?
首先,我按照以下步骤在 JanusGraph 中创建一个图形。
conf/janusgraph-cassandra-configurationgraph.propertiesindex.search.backend = elasticsearch
index.search.hostname = 127.0.0.1
index.search.elasticsearch.transport-scheme = http
Run Code Online (Sandbox Code Playgroud)
将 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 start
运行 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()
Run Code Online (Sandbox Code Playgroud)
关闭 janusgraph,运行 bin/janusgraph.sh 停止
将 conf/janusgraph-cassandra-es.properties 复制到 conf/KG.properties
在 conf/KG.properties 顶部添加以下两行
gremlin.graph=org.janusgraph.core.ConfiguredGraphFactory
graph.graphname=KG
Run Code Online (Sandbox Code Playgroud)
KG: conf/KG.properties
Run Code Online (Sandbox Code Playgroud)
将“scripts/empty-sample.groovy”添加到“org.apache.tinkerpop.gremlin.jsr223.ScriptFileGremlinPlugin:”
打开 script/empty-sample.groovy,将最后一行修改为: …
如何从 JavaGraphTraversal对象输出 Gremlin 查询?默认输出 ( graphTraversal.toString()) 看起来[HasStep([~label.eq(brand), name.eq(Nike), status.within([VALID])])]不容易阅读。
我问的问题差不多就像你在这里看到的那样,但是必须使用groovy而不是java语法.理想情况下,答案非常简洁.
我有一个人顶点的简单图表.每个人都有一个"年龄"属性,列出该人的年龄.还有"worksFor"标记的边连接成对的顶点.我希望看到边缘两端的人具有相同年龄属性的所有边缘.
然后,我想要一个类似的查询,其中两个年龄相差不到3年.
如前所述,这应该是groovy,而不是Java语法.Gremlin 3是首选,但Gremlin 2的答案是可以接受的.
我是Titan/Gremlin/TinkerPop3的新手,正在玩/尝试Restful API Interface来创建/修改/删除数据库中的顶点/边缘.
我基本上想看看是否有可能使用tinkerpop3公开的API进行图形处理.
我使用以下命令在gremlin服务器中创建了现代图形:
gremlin> graph = TinkerFactory.createModern()
gremlin> g = graph.traversal()
Run Code Online (Sandbox Code Playgroud)
我可以通过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":{}}}
Run Code Online (Sandbox Code Playgroud)
但以下内容不会返回任何内容:
curl http://localhost:8182 -d '{"gremlin": "g.V()"}'
{"requestId":"8ba30f35-31e7-46ff-b16e-3e01fb9a49bf","status":{"message":"","code":200,"attributes":{}},"result":{"data":[],"meta":{}}}
Run Code Online (Sandbox Code Playgroud)
我做了我的阅读:http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#_connecting_via_rest
非常感谢任何帮助.提前致谢.
在gremlin,
s = graph.traversal()
g = graph.traversal(computer())
我知道第一个用于OLTP,第二个用于OLAP.我知道OLAP和OLTP在定义级别上的区别.我对此有以下查询:
如何
提前致谢.
我正在努力与格雷姆林交手.彻底阅读了文档后,我似乎仍然在概念上苦苦思索.
我正在创建一个基本的新闻源,遵循Neo4j文档中的模型:
http://neo4j.com/docs/snapshot/cypher-cookbook-newsfeed.html
我实际上正在使用titandb,但遵循上面显示的相同类型的原则/架构.
到目前为止,我已经创建了一个user顶点图,它通过friend边连接.
我可以添加一个新的post顶点并通过posted边连接到user顶点,如下所示:
def activity = graph.addVertex(T.label, "post");
activity.property("post_id", post_id);
activity.property("time", time);
activity.property("body", body);
def g = graph.traversal();
def user = g.V().hasLabel("user").has("userid", userid).next();
user.addEdge("posted", activity, "time", time);
Run Code Online (Sandbox Code Playgroud)
但是,我需要能够在一个Gremlin脚本中执行以下操作:
post如上所述创建新顶点.posted之间的旧边.但只有当一个帖子存在.userpostpost顶点附加到新顶点.userpostedpost顶点,则post通过next边将其附加到新添加的顶点.最终为每个用户创建长流量的帖子.我一直在玩,使用反复试验,现在好像几个小时,似乎无法理解它.
任何帮助将不胜感激.
我有两个顶点之间的边缘8392 ---> 532500664,标签"has"仍然是
g.V(8392).out("has").has("id",532500664)
Run Code Online (Sandbox Code Playgroud)
不工作告诉我如何实现这一目标?
注意= g是图遍历对象
关于开始使用ScyllaDB与JanusGraph和Tinperpop3.
现在,我将处理<200 GB的数据,所以我想在我自己(基于xeon)的计算机上做所有事情.
我的问题主要是:某些版本是否彼此不兼容?
对于ScyllaDB,我可能会选择:https: //www.scylladb.com/download/debian9/
但是JanusGraph没有将ScyllaDB列为(测试和)兼容,虽然我已经读过几个地方可以使用 https://github.com/JanusGraph/janusgraph/releases/tag/v0.2.2
而对于Tinkerpop3,我会使用他们最新版本的3.3.4 http://tinkerpop.apache.org/docs/current/reference/