JanusGraph through Java creates Empty Vertices on Unique Index

65 views
Skip to first unread message

l.gut...@web.de

unread,
Jan 17, 2018, 3:38:57 AM1/17/18
to JanusGraph users

so i´m writing an importer for JanusGraph as a Java Application.

I have a primary Attribute "title" for every Node and I want a way to submit every Node only once. There should not be any title twice.

That´s why i made a unique index on the property Key of title in my Gremlin-Server. This is fine, and if i´m working on Console inserting duplicate titles gives an Error and nothing else happens.

For working with Java i have made the following 2 Additions to my Gremlin-Server if it matters:

graph.tx().onClose(Transaction.CLOSE_BEHAVIOR.ROLLBACK) graph.tx().onReadWrite(Transaction.READ_WRITE_BEHAVIOR.MANUAL)

My Index-Creation-Gremlin Looks like this:

mgmt=graph.openManagement()
title
=mgmt.makePropertyKey('title').dataType(String.class).cardinality(Cardinality.SINGLE).make()
mgmt.buildIndex("byTitle",Vertex.class).addKey(title).unique().buildCompositeIndex()
mgmt.commit()


However, if i use this Code:

public void addNode(String title){
    Map<String,Object> params=new HashMap<>();
    params.put("t", title);
    String commit="graph.addVertex('title',t)";
    jCon.submit("graph.tx().open()");
    jCon.submit(commit,params);
    jCon.submit("graph.tx().commit()");
}

it also produces an Error for duplicate titles BUT an Empty Vertex on the Server is created.

This also appears if using "g.addV()" instead of "graph.addVertex()".

Can someone else reproduce this? I don´t think this is intended behaviour.

Note: I´m adding more variables then just the title, the Vertex is completely Empty.

Reply all
Reply to author
Forward
0 new messages