我有一个看起来像的图表
a --father_of--> 1 --wife_of--> b --father_of-->2 --wife_of--> c --father_of--> 3--wife_of--> d --father_of --> 5--wife_of-->e
Run Code Online (Sandbox Code Playgroud)
我想写一个查询,它给了我从树开始的所有父亲
我可以写一个级别
g.V('name','a').out(father_of).out(wife_of)
这给了b
如何编写一个递归查询,将b作为管道的输入,以便查询给出节点b,c,d和e.
我正在尝试使用follwing命令将以下graphSon格式转换为图形实例
graph.io(IoCore.graphson()).reader().create().readGraph(stream, graph);
Run Code Online (Sandbox Code Playgroud)
但是在运行时将GRaphSON转换为下面给出的图形实例
{"id":0,
"label":"buyer",
"outE":
{"email_is":
[{"id":0,"inV":1,
"properties":{"weight":1}
}
]}
,"properties":
{"buyer":
[{
"id":0,"value":"buyer0"
}]
,"age":
[{
"id":1,"value":10}]
}}
{"id":1,
"label":"email",
"inE":
{ "email_is":
[{"id":1,"outV":0,
"properties":{"weight":1}}
]}
,"properties":
{"email":
[{"id":2,
"value":"email0"
}]
}}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:745)Caused by: java.lang.IllegalArgumentException: Invalid vertex provided: null
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at com.thinkaurelius.titan.graphdb.vertices.AbstractVertex.addEdge(AbstractVertex.java:149)
at com.thinkaurelius.titan.graphdb.vertices.AbstractVertex.addEdge(AbstractVertex.java:23)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.lambda$null$57(GraphSONReader.java:114)
at java.util.Iterator.forEachRemaining(Iterator.java:116)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.lambda$readGraph$58(GraphSONReader.java:108)
at java.util.HashMap$EntrySet.forEach(HashMap.java:1035)
at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONReader.readGraph(GraphSONReader.java:108)
at pluradj.titan.tinkerpop3.example.JavaExample2.main(JavaExample2.java:50)
... 6 more
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我一个更简单的方法来制作GRAPHSON文件,因为使用StringWriter和JSONWRiter类是一项非常繁琐的任务.
我想知道如何有一个以嵌套格式返回结果的gremlin查询.假设有如下属性图:
USER
和PAGE
一些特性,如顶点AGE
为USER
顶点;
FOLLOW
边缘USER
和PAGE
;
我正在寻找一个单一的高效查询,它为所有年龄大于20岁的用户提供所有跟随的用户.我可以使用来自应用程序端的简单循环来执行该操作,并且每次迭代使用简单的遍历查询.不幸的是,这样的解决方案对我来说效率不高,因为它会产生大量查询,并且在这种情况下网络延迟可能很大.
我正在开发一个软件系统(Graph Database)来研究多个组件之间的互连.最终可能会有大约30 TB的数据.我想知道在选择正确的数据库时需要考虑的因素.
我正在寻找的一些选项是Apache Giraph,TitanDB.我也想知道像neo4j或OrientDB这样规模较小的数据库本身是否可行
我正在使用Gremlin处理Titan Graph。而且我正在设法找到一种非常具体的关系。
我有标签,属性以及可能的start和endNode列表。
我希望所有关系都与此相匹配。
我已经有了这个来获取所有匹配标签和属性的关系:
GraphTraversal<Edge, Edge> tempOutput = g.E().hasLabel(relationshipStorage.getId());
if(relationshipStorage.getProperties() != null)
{
for (Map.Entry<String, Object> entry : relationshipStorage.getProperties().entrySet())
{
if (tempOutput == null)
{
break;
}
tempOutput = tempOutput.has(entry.getKey(), entry.getValue());
}
}
Run Code Online (Sandbox Code Playgroud)
但是我没有找到通过特定的start和endNode来获得它的方法。我不想在两个节点之间有多个边缘。我只想要具有特定顶点的一条边。
我们正在使用Titan 1.0.0和Cassandra版本3.9.0-1,来自CentOs-7系统上的datastax- ddc.我们看到一些奇怪的问题,例如:
具有相同边ID的多个边,这些边上的少数属性的值不同.
gV().has('msid',6171699).outE('prio_child').has('hostid_e',153).as('e')inV().has('msid',58713376).select( 'e')==> e [ 54ekdatm-1lezwb4-45cl-195s9km8 ] [3471761488-prio_child-> 98305011872] ==> e [ 54ekdatm-1lezwb4-45cl-195s9km8 ] [3471761488-prio_child-> 98305011872]
在应用更多限制后获得更多结果
gV().has('msid',6171699).outE('prio_child').count()
==> 60
gV().has('msid',6171699).outE('prio_child').has('hostid_e,153).count()
==> 66
我甚至尝试过设置ConsistencyModifier.LOCK,正如Titan文档最终一致后端所建议的那样,但它没有帮助.我仍然得到任意结果.
我需要返回'posts'顶点,但这些帖子有一些'like'边缘,我怎样才能将该帖子的'likes'边缘的数量作为该边缘的属性返回,如下所示:
{title:'lorem ipsum .....',内容:'yadayadayada', 喜欢:6 <----}
我需要返回该组中的一些群组和人员,如下所示:
Run Code Online (Sandbox Code Playgroud)Group A -----Person A -----Person B -----Person C Group B -----Person D -----Person E -----Person F
我怎么能用gremlin做到这一点.它们连接到具有边缘的组.
假设我有一个属性值列表作为ArrayList,如何通过列表中的值过滤节点。
这样可能吗...
g.V().filter {it.get().value("name") in list}
Run Code Online (Sandbox Code Playgroud)
也与TinkerPop 2.x兼容
titan ×9
gremlin ×7
janusgraph ×2
neo4j ×2
tinkerpop ×2
tinkerpop3 ×2
cassandra ×1
giraph ×1
graph ×1
java ×1