为什么不能在Java中使用Gremlin为新顶点设置ID? [英] Why can't I set the Id for a new vertex using Gremlin in Java?

查看:184
本文介绍了为什么不能在Java中使用Gremlin为新顶点设置ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Java和Neo4j图的Gremlin. 我创建了3个新顶点,并尝试将其ID设置为1,2,3,但似乎无法正常工作,我在做什么错了?

I'm using Gremlin with Java and a Neo4j graph. I create 3 new vertices and try to set their Ids to 1,2,3 but it does not seem to be working, what am I doing wrong?

Vertex v1 = g.addVertex(1);
v1.setProperty("name","jim");
Vertex v2 = g.addVertex(2);
v2.setProperty("name","bob");
Vertex v3 = g.addVertex(3);
v3.setProperty("name","fred");

//iterate through the vertices and get their id's (shouldn't they be 1,2, and 3 ??

for (Vertex V:GVs)
    System.out.println(V.getId());

返回:

15
16
17

这是为什么?如何将ID设置为1,2,3?还可以将ID设置为字符串吗?

Why is this? How can I set the Ids to 1,2,3? Also can I set the Ids to strings instead?

谢谢!

推荐答案

Neo4j为您分配新数据的ID,除非您使用BatchInserter实用程序,否则无法设置它们. Gremlin默默地忽略了您的ID.

Neo4j is assigning the IDs of new data for you, you can't set them, except when you use the BatchInserter utility. Gremlin is silently ignoring your IDs.

这篇关于为什么不能在Java中使用Gremlin为新顶点设置ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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