I am trying to create vertex and edges in Titan graph database (Titan1.0.0)..
gremlin> graph = TitanFactory.open('titan-1.0.0-hadoop1/conf/titan-cassandra-es.properties')
gremlin> t1 = graph.addVertex(label, "Testbed", "Name", "testbed1","Status","A","TId",101)
==>v[1228816568]
gremlin> r2= graph.addVertex(label, "Router", "RStatus","F","RId",1002, "TId", 101)
==>v[3686424680]
gremlin> t1.addEdge("tbConRtr", r2)
==>e[kblqtz-kblsxk-d6vp-1oysvhk][1228816568-tbConRtr->3686424680]
Questions:
1) Why is the vertex number returned here are not sequence and it is some random number? For addEdge
step also it is creating edge with some random value ( kblqtz-kblsxk-d6vp-1oysvhk
)
e[kblqtz-kblsxk-d6vp-1oysvhk][1228816568-tbConRtr->3686424680]
2) I want my TId
value should be unique I have tried the following and got Error Msg:
gremlin> mgmt.buildIndex("TId",Vertex.class).addKey(TId).unique().buildCompositeIndex();
No such property: TId for class: groovysh_evaluate
How can I create a unique property value in Titan database?
Kindly help me to resolve this.
The error No such property: TId
indicates that you are trying to use a variable TId
that has not been initialized. You should define the vertex property before trying to index it
gremlin> graph = TitanFactory.open('conf/titan-cassandra-es.properties') ==>standardtitangraph[cassandrathrift:[127.0.0.1]] gremlin> mgmt = graph.openManagement() ==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@4b97b3d2 gremlin> TId = mgmt.makePropertyKey("TId").dataType(Integer.class).cardinality(Cardinality.SINGLE).make() ==>TId gremlin> mgmt.buildIndex("TId",Vertex.class).addKey(TId).unique().buildCompositeIndex() ==>TId gremlin> mgmt.commit() ==>null gremlin> t1 = graph.addVertex(label, "Testbed", "Name", "testbed1","Status","A","TId",101) ==>v[4200] gremlin> r2= graph.addVertex(label, "Router", "RStatus","F","RId",1002, "TId", 101) Adding this property for key [TId] and value [101] violates a uniqueness constraint [TId]
Please refer to the Titan documentation on schema and data modeling and also indexing for better performance .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.