泰坦db如何列出所有图形索引

问题描述:

我一直在看管理系统,但有些东西仍然没有我。基本上我想要做的是:泰坦db如何列出所有图形索引

  • 列出所有基于边缘的索引(包括以顶点为中心)。
  • 列出所有基于顶点的索引(如果索引附加到标签,则基于每个标签)。

这基本上就像映射出图模式。

我试过一些东西,但我最多只能得到部分数据。

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. 

任何帮助填补空白将是有益的。

我想知道:

  • 我如何才能找到连接到一个标签(或标签附加到一个索引),通过indexOnly()
  • 如何列出通过buildEdgeIndex设定边缘指标索引()和它们各自的边缘标签?

在此先感谢。

其他信息: 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() 

现在让我们再次拉索引信息了。

gremlin> m = g.getManagementSystem() 
==>com.t[email protected]2f414e82 

gremlin> // get the index by its name 
gremlin> index = m.getGraphIndex("god-name") 
==>com.thinkau[email protected]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) 
==>[email protected] 

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() 
==>[email protected] 

gremlin> // finally get the schema type (that's the vertex label that's used in .indexOnly()) 
gremlin> sse.getSchemaType() 
==>god 

干杯, 丹尼尔

+0

惊人的感谢!我已经算出了它的一部分,但是没有得到顶点标签。 – 2014-09-11 13:28:52