D.M*_*ill 11 gremlin titan tinkerpop
我一直在关注管理系统,但有些事情仍然无法实现.基本上我想做的是:
它基本上就像映射图模式一样.
我尝试了一些东西,但我只获得了部分数据.
g.getIndexdKeys(<Vertex or Edge>);
//basic information. Doesn't seem to return any buildEdgeIndex() based indexes
mgmt.getVertexLabels();
// gets labels, can't find a way of getting indexes attached to these labels.
mgmt.getGraphIndexes(Vertex.class);
// works nicely I can retrieve Vertex indexes and get pretty much any
// information I want out of them except for information regarding
// indexOnly(label). So I can't tell what label these indexes are attached to.
mgmt.getGraphIndexes(Edge.class);
// doesn't seem to return any buildEdgeIndex() indexes.
Run Code Online (Sandbox Code Playgroud)
填补空白的任何帮助都会有所帮助.
我想知道:
提前致谢.
额外信息: Titan 0.5.0,Cassandra后端,通过rexster.
它并不是真的很直接,因此我将使用一个例子来展示它.
让我们从神的图表开始+神名的另一个索引:
g = TitanFactory.open("conf/titan-cassandra-es.properties")
GraphOfTheGodsFactory.load(g)
m = g.getManagementSystem()
name = m.getPropertyKey("name")
god = m.getVertexLabel("god")
m.buildIndex("god-name", Vertex.class).addKey(name).unique().indexOnly(god).buildCompositeIndex()
m.commit()
Run Code Online (Sandbox Code Playgroud)
现在让我们再次拉出索引信息.
gremlin> m = g.getManagementSystem()
==>com.thinkaurelius.titan.graphdb.database.management.ManagementSystem@2f414e82
gremlin> // get the index by its name
gremlin> index = m.getGraphIndex("god-name")
==>com.thinkaurelius.titan.graphdb.database.management.TitanGraphIndexWrapper@e4f5395
gremlin> // determine which properties are covered by this index
gremlin> gn.getFieldKeys()
==>name
//
// the following part shows what you're looking for
//
gremlin> import static com.thinkaurelius.titan.graphdb.types.TypeDefinitionCategory.*
gremlin> // get the schema vertex for the index
gremlin> sv = m.getSchemaVertex(index)
==>god-name
gremlin> // get index constraints
gremlin> rel = sv.getRelated(INDEX_SCHEMA_CONSTRAINT, Direction.OUT)
==>com.thinkaurelius.titan.graphdb.types.SchemaSource$Entry@5162bf3
gremlin> // get the first constraint; no need to do a .hasNext() check in this
gremlin> // example, since we know that we will only get a single entry
gremlin> sse = rel.iterator().next()
==>com.thinkaurelius.titan.graphdb.types.SchemaSource$Entry@5162bf3
gremlin> // finally get the schema type (that's the vertex label that's used in .indexOnly())
gremlin> sse.getSchemaType()
==>god
Run Code Online (Sandbox Code Playgroud)
干杯,丹尼尔
| 归档时间: |
|
| 查看次数: |
5774 次 |
| 最近记录: |