2014-09-06 13 views
11

Szukałem systemu zarządzania, ale niektóre rzeczy wciąż mi umykają. Zasadniczo chcę, aby:Titan db jak wyświetlić wszystkie indeksy grafów

  • Lista wszystkich indeksów opartych na Edge (w tym vertex centric).
  • Lista wszystkich indeksów opartych na Vertex (dla każdej etykiety, jeśli indeks jest dołączony do etykiety).

Jest to zasadniczo podobne do mapowania schematu wykresu.

Próbowałem kilku rzeczy, ale otrzymuję tylko częściowe dane w najlepszym razie.

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. 

Pomocna będzie pomoc w wypełnieniu pustki.

Id lubią wiedzieć:

  • Jak znajdę indeksy dołączone do etykiety (lub etykiecie dołączonej do indeksu) poprzez indexOnly()
  • Jak wylistować indeksy brzegowe określone poprzez buildEdgeIndex() i ich krawędzie Etykiety?

Z góry dziękuję.

Dodatkowe informacje: Titan 0.5.0, backend Cassandra, przez rexster.

Odpowiedz

9

to nie jest proste, dlatego pokażę to na przykładzie.

Zacznijmy od wykresu Bogów + dodatkowy indeks dla imion Boga

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

Teraz ponownie wyciągnąć informacje z indeksu.

gremlin> m = g.getManagementSystem() 
==>com.thinkaurelius.titan.graphdb.database.management[email protected] 

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

niesamowite dzięki! Już wcześniej odkryłem część tego, ale nie udało mi się zdobyć etykiety wierzchołków. –

Powiązane problemy