在DSE Graph中,顶点的唯一id似乎是community_id。
我发现这可行(id 很长):
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:
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}]
应该有一个更简洁的方法...... 感谢任何帮助:)
最佳答案
实际上我找到了:
ids 可以写成这样的字符串形式:"vertexLabel:community_id:member_id"
对于上面的示例id="User:1488246528:512"
:
v = g.V().hasId("User:1488246528:512").next()
v = g.V("User:1488246528:512").next()
返回特定的顶点
到目前为止,我不知道如何简洁地打印 Vertex 的 id(作为字符串),以便可以在 V() 或 hasId() 中使用它。我目前所做的是:
LinkedHashMap id = ((LinkedHashMap)v.id());
String idStr = v.label()+":"+id.get("community_id")+":"+id.get("member_id");
关于datastax - 如何在Datastax DSE 5.0 Graph中以简洁的方式通过顶点id进行查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41231293/