如何以简洁的方式在Datastax DSE 5.0图形中按顶点ID查询? [英] how to query by vertex id in Datastax DSE 5.0 Graph in a concise way?

查看:90
本文介绍了如何以简洁的方式在Datastax DSE 5.0图形中按顶点ID查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在DSE图中,顶点的唯一ID似乎是community_id。

It seems that the unique id for vertices is community_id in DSE Graph.

我发现这可行(id长):

I have found that this works (id is long) :

   v = g.V().has("VertexLabel","community_id",id).next()

没有一项工作:

   v = g.V("community_id",id).next()
   v = g.V("community_id","VertexLabel:"+id).next()
   v = g.V(id).next()
   v = g.V().hasId(id).next()
   v = g.V().hasId("VertexLabel:"+id).next()
   v = g.V("VertexLabel:"+id).next()

编辑

经过一些调查,我发现对于顶点v,v.id()返回LinkedHashMap:

After some investigation I found that for a vertex v, v.id() returns a LinkedHashMap:

Vertex v = gT.next();
Object id = v.id();
System.out.println(id);
System.out.println(id.getClass());
System.out.println(g.V().hasId(id).next());
System.out.println(g.V(id).next());

上面的照片:

{~label=User, community_id=1488246528, member_id=512}
class java.util.LinkedHashMap
v[{~label=User, community_id=1488246528, member_id=512}]
v[{~label=User, community_id=1488246528, member_id=512}]

应该有一种更简洁的方法...
可以得到任何帮助:)

There should be a more concise way ... any help is appreciated :)

推荐答案

实际上我找到了它:

id可以用以下字符串形式编写: vertexLabel:community_id:member_id

ids can be written in this String form: "vertexLabel:community_id:member_id"

因此,对于上面的示例 id = User:1488246528:512

So for the example above id="User:1488246528:512":

v = g.V().hasId("User:1488246528:512").next()
v = g.V("User:1488246528:512").next()

返回特定的顶点

现在我不知道如何以简洁的方式打印顶点的ID(作为字符串)的好方法,以便可以在V()或hasId()中使用它。 o是:

Till now I don't know of a good way how to print concisely the id (as a string) of a Vertex so it can be used in V() or in hasId() .. what I currently do is:

LinkedHashMap id = ((LinkedHashMap)v.id());
String idStr = v.label()+":"+id.get("community_id")+":"+id.get("member_id");

这篇关于如何以简洁的方式在Datastax DSE 5.0图形中按顶点ID查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆