2014-09-06 18 views
11

Ich habe mir das Managementsystem angeschaut, aber einige Dinge entziehen sich mir immer noch. Im Wesentlichen, was ich tun möchte, ist:Titan db wie listet man alle graphischen Indexe auf

  • Liste alle Edge-basierte Indizes (einschließlich Eckpunkt zentrisch).
  • Alle Vertex-basierten Indizes auflisten (auf einer Label-Basis, wenn der Index an ein Label angehängt ist).

Es ist im Grunde wie das Diagramm Schema.

Ich habe ein paar Dinge ausprobiert, aber ich bekomme nur Teildaten bestenfalls.

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. 

Jede Hilfe, die die Lücke füllt, wäre hilfreich.

Id gerne wissen:

  • Wie kann ich die Indizes finde auf ein Etikett (oder Etikett an einen Index gebunden) über indexOnly()
  • Wie stelle ich den Rand Indizes über buildEdgeIndex eingestellt() und ihre jeweiligen Kanten-Labels?

Vielen Dank im Voraus.

Zusätzliche Informationen: Titan 0.5.0, Cassandra-Backend, via Rexster.

Antwort

9

es ist nicht wirklich geradlinig, daher werde ich es anhand eines Beispiels zeigen.

Beginnen wir mit dem Graph der Götter + einen zusätzlichen Index für Gott Namen beginnen:

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() 

Lassen Sie uns jetzt die Indexinformationen wieder herausziehen.

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 

Cheers, Daniel

+0

erstaunlich Dank! Ich hatte bereits einen Teil davon herausgefunden, aber ich vermisste die Scheitelmarke. –

Verwandte Themen