标签:全文检索 ons ram 完成 class 方式 xtend .text 不能
g.V().has(‘name‘,‘hercules‘)
g.E().has(‘reason‘, textContains(‘loves‘))
JanusGraphManagement.buildIndex(String,Class)
// 在graph中有事务执行时绝不能创建索引(否则可能导致死锁) graph.tx().rollback() mgmt = graph.openManagement() name = mgmt.getPropertyKey(‘name‘) age = mgmt.getPropertyKey(‘age‘) // 构建根据name查询vertex的组合索引 mgmt.buildIndex(‘byNameComposite‘,Vertex.class).addKey(name).buildCompositeIndex() // 构建根据name和age查询vertex的组合索引 mgmt.buildIndex(‘byNameAndAgeComposite‘,Vertex.class).addKey(name).addKey(age).buildCompositeIndex() mgmt.commit() //等待索引生效 mgmt.awaitGraphIndexStatus(graph,‘byNameComposite‘).call() mgmt.awaitGraphIndexStatus(graph,‘byNameAndAgeComposite‘).call() //对已有数据重新索引 mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getGraphIndex("byNameComposite"),SchemaAction.REINDEX).get() mgmt.updateIndex(mgmt.getGraphIndex("byNameAndAgeComposite"),SchemaAction.REINDEX).get() mgmt.commit()
graph.tx().rollback()//Never create new indexes while a transaction is active mgmt = graph.openManagement() name = mgmt.getPropertyKey(‘name‘) mgmt.buildIndex(‘byNameUnique‘,Vertex.class).addKey(name).unique().buildCompositeIndex() mgmt.commit() //Wait for the index to become available mgmt.awaitGraphIndexStatus(graph,‘byNameUnique‘).call() //Reindex the existing data mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getGraphIndex("byNameUnique"),SchemaAction.REINDEX).get() mgmt.commit()
graph.tx().rollback()//Never create new indexes while a transaction is active mgmt = graph.openManagement() name = mgmt.getPropertyKey(‘name‘) age = mgmt.getPropertyKey(‘age‘) mgmt.buildIndex(‘nameAndAge‘,Vertex.class).addKey(name).addKey(age).buildMixedIndex("search") mgmt.commit() //Wait for the index to become available mgmt.awaitGraphIndexStatus(graph,‘nameAndAge‘).call() //Reindex the existing data mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getGraphIndex("nameAndAge"),SchemaAction.REINDEX).get() mgmt.commit()
mgmt.buildIndex(‘nameAndAge‘,Vertex.class).addKey(name,Mapping.TEXT.getParameter()).addKey(age,Mapping.TEXT.getParameter()).buildMixedIndex("search")
g.V().has(‘name‘, textContains(‘hercules‘)).has(‘age‘, inside(20,50)) g.V().has(‘name‘, textContains(‘hercules‘)) g.V().has(‘age‘, lt(50))
//Never create new indexes while a transaction is active graph.tx().rollback() mgmt = graph.openManagement() //创建一个新的属性 location = mgmt.makePropertyKey(‘location‘).dataType(Geoshape.class).make() nameAndAge = mgmt.getGraphIndex(‘nameAndAge‘) //修改索引 mgmt.addIndexKey(nameAndAge, location) mgmt.commit() //Wait for the index to become available mgmt.awaitGraphIndexStatus(graph,‘nameAndAge‘).call() //Reindex the existing data mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getGraphIndex("nameAndAge"),SchemaAction.REINDEX).get() mgmt.commit()
g.V().has(‘name‘, textContains(‘hercules‘)).order().by(‘age‘, decr).limit(10)
//Never create new indexes while a transaction is active graph.tx().rollback() mgmt = graph.openManagement() name = mgmt.getPropertyKey(‘name‘) god = mgmt.getVertexLabel(‘god‘) //只索引有god这一label的顶点 mgmt.buildIndex(‘byNameAndLabel‘,Vertex.class).addKey(name).indexOnly(god).buildCompositeIndex() mgmt.commit() //Wait for the index to become available mgmt.awaitGraphIndexStatus(graph,‘byNameAndLabel‘).call() //Reindex the existing data mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getGraphIndex("byNameAndLabel"),SchemaAction.REINDEX).get() mgmt.commit()
h = g.V().has(‘name‘,‘hercules‘).next()
g.V(h).outE(‘battled‘).has(‘time‘, inside(10,20)).inV()
//Never create new indexes while a transaction is active graph.tx().rollback() mgmt = graph.openManagement() //找到一个property key time = mgmt.getPropertyKey(‘time‘) // 找到一个label battled = mgmt.getEdgeLabel(‘battled‘) // 创建vertex-centric index mgmt.buildEdgeIndex(battled,‘battlesByTime‘,Direction.BOTH,Order.decr, time) mgmt.commit() //Wait for the index to become available mgmt.awaitGraphIndexStatus(graph,‘battlesByTime‘).call() //Reindex the existing data mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getGraphIndex("battlesByTime"),SchemaAction.REINDEX).get() mgmt.commit()
graph.tx().rollback()//Never create new indexes while a transaction is active mgmt = graph.openManagement() time = mgmt.getPropertyKey(‘time‘) rating = mgmt.makePropertyKey(‘rating‘).dataType(Double.class).make() battled = mgmt.getEdgeLabel(‘battled‘) mgmt.buildEdgeIndex(battled,‘battlesByRatingAndTime‘,Direction.OUT,Order.decr, rating, time) mgmt.commit() //Wait for the index to become available mgmt.awaitRelationIndexStatus(graph,‘battlesByRatingAndTime‘,‘battled‘).call() //Reindex the existing data mgmt = graph.openManagement() mgmt.updateIndex(mgmt.getRelationIndex(battled,‘battlesByRatingAndTime‘),SchemaAction.REINDEX).get() mgmt.commit()
h = g.V().has(‘name‘,‘hercules‘).next() g.V(h).outE(‘battled‘).property(‘rating‘,5.0)//Add some rating properties g.V(h).outE(‘battled‘).has(‘rating‘, gt(3.0)).inV() g.V(h).outE(‘battled‘).has(‘rating‘,5.0).has(‘time‘, inside(10,50)).inV() g.V(h).outE(‘battled‘).has(‘time‘, inside(10,50)).inV()
h = g..V().has(‘name‘,‘hercules‘).next() g.V(h).local(outE(‘battled‘).order().by(‘time‘, decr).limit(10)).inV().values(‘name‘) g.V(h).local(outE(‘battled‘).has(‘rating‘,5.0).order().by(‘time‘, decr).limit(10)).values(‘place‘)
标签:全文检索 ons ram 完成 class 方式 xtend .text 不能
原文地址:http://www.cnblogs.com/jiyuqi/p/7132986.html