图数据库Titan(Gremlin)对索引的创建

对点上的属性创建索引,注意:We can retrieve it from the index using the getVertices(String,Object) method:
TitanGraph g = TitanFactory.open("/tmp/titan"); 
g.createKeyIndex("name",Vertex.class); 
Vertex juno = g.addVertex(null); 
juno.setProperty("name", "juno"); 
juno = g.getVertices("name","juno").iterator().next();
(常用这种:Iterable< Vertex > results =  g.getVertices("name","juno") 
对边上的属性创建索引:
g.createKeyIndex("time",Edge.class); 
Vertex jena = g.addVertex(null); 
jena.setProperty("name", "jena"); 
Edge e = jena.addEdge("knows",juno); 
e.setProperty("time",99); 
g.getEdges("time",99).iterator().next();

Titan的官网上说必须首先建立索引,之后才能写入数据: Key indices need to be created before the key is first used。但是我测试Gremlin.sh发现可以先写数据再建索引。
 
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值