Why can't I set the Id for a new vertex using Gremlin in Java?

天大地大妈咪最大 提交于 2019-12-11 03:46:55

问题


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());

returns:

15
16
17

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

Thanks!


回答1:


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.



来源:https://stackoverflow.com/questions/10322041/why-cant-i-set-the-id-for-a-new-vertex-using-gremlin-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!