Problem of uniqueness of key


n0b0...@...
 

I'm trying to find a solution of "primary key" for vertex and I found a discussion in 2017


Then I tried on my janusgraph 0.5.2 but found the uniqueness restrain seems not working:

gremlin> graph = JanusGraphFactory.open('conf/docker-env.conf')
==>standardjanusgraph[cql:[127.0.0.1]]
gremlin> JanusGraphFactory.drop(graph)
==>null
gremlin> graph = JanusGraphFactory.open('conf/docker-env.conf')
==>standardjanusgraph[cql:[127.0.0.1]]
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@4f5c757c
gremlin> name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(Cardinality.SINGLE).make()
==>name
gremlin> nameIndex = mgmt.buildIndex('nameIndex', Vertex.class).addKey(name).unique().buildCompositeIndex()
==>nameIndex
gremlin> mgmt.commit()
==>null
gremlin> graph.addVertex('name', 'huupon')
==>v[4192]
gremlin> graph.addVertex('name', 'huupon')
==>v[4112]
gremlin> 


My backend is cassandra and elasticsearch, does anyone knows what did I miss?


Chen Wu <cjx...@...>
 

Can you try to call graph.tx().commit() to see what happens? Maybe the constraint check is carried out when you commit.

在 2020年6月18日星期四 UTC+8上午10:37:59,n0...@...写道:

I'm trying to find a solution of "primary key" for vertex and I found a discussion in 2017


Then I tried on my janusgraph 0.5.2 but found the uniqueness restrain seems not working:

gremlin> graph = JanusGraphFactory.open('conf/docker-env.conf')
==>standardjanusgraph[cql:[127.0.0.1]]
gremlin> JanusGraphFactory.drop(graph)
==>null
gremlin> graph = JanusGraphFactory.open('conf/docker-env.conf')
==>standardjanusgraph[cql:[127.0.0.1]]
gremlin> mgmt = graph.openManagement()
==>org.janusgraph.graphdb.database.management.ManagementSystem@4f5c757c
gremlin> name = mgmt.makePropertyKey('name').dataType(String.class).cardinality(Cardinality.SINGLE).make()
==>name
gremlin> nameIndex = mgmt.buildIndex('nameIndex', Vertex.class).addKey(name).unique().buildCompositeIndex()
==>nameIndex
gremlin> mgmt.commit()
==>null
gremlin> graph.addVertex('name', 'huupon')
==>v[4192]
gremlin> graph.addVertex('name', 'huupon')
==>v[4112]
gremlin> 


My backend is cassandra and elasticsearch, does anyone knows what did I miss?